Блог*
#prog #rust #rustlib #article Kani — bit-precise model checker for Rust. Верификатор, который исполняет код символически и потому эффективно проверяет код на всех возможных входах. Если код (без внесения ограничений на работу kani) проходит проверку, то его…
#prog #rust #article
How Kani helped find bugs in Hifitime
Hifitime is a scientifically accurate time management library that provides nanosecond precision of durations and time computations for 65 thousand centuries in most time scales (also called time systems). It is useful wherever a monotonic clock is needed, even in the presence of leap second or remote time corrections (like for Network Time Protocol or Precise Time Protocol). It is suitable for desktop applications and for embedded systems without a floating point unit (FPU). It also supports the typical features of date time management libraries, like the formatting and parsing of date times in a
The purpose of this blog post is to show how Kani helped solve a number of important non-trivial bugs in hifitime.
How Kani helped find bugs in Hifitime
Hifitime is a scientifically accurate time management library that provides nanosecond precision of durations and time computations for 65 thousand centuries in most time scales (also called time systems). It is useful wherever a monotonic clock is needed, even in the presence of leap second or remote time corrections (like for Network Time Protocol or Precise Time Protocol). It is suitable for desktop applications and for embedded systems without a floating point unit (FPU). It also supports the typical features of date time management libraries, like the formatting and parsing of date times in a
no_std environment using the typical C89 tokens, or a human friendly approximation of the difference between dates. For scientific and engineering applications, it is mostly tailored to astronomy (with the inclusion of the UT1 time scale), astrodynamics (with the ET and TDB time scales), and global navigation satellite systems (with the GPS, Galileo, and BeiDou time scales).The purpose of this blog post is to show how Kani helped solve a number of important non-trivial bugs in hifitime.
Kani Rust Verifier Blog
How Kani helped find bugs in Hifitime
Kani is a verification tool that can help you systematically test properties about your Rust code. To learn more about Kani, check out the Kani tutorial and our previous blog posts.
🔥2💩2
#prog #rust #article
Modular Errors in Rust
...If there’s one thing I wish for you to take away, it’s that error handling is hard, but it’s worth it to learn. Because I’m tired of having to deal with lazy kitchen-sink-type errors.
Modular Errors in Rust
...If there’s one thing I wish for you to take away, it’s that error handling is hard, but it’s worth it to learn. Because I’m tired of having to deal with lazy kitchen-sink-type errors.
Sabrina Jewson
Modular Errors in Rust
It is thankfully common wisdom nowadays that documentation must be placed as near as possible to the code it documents, and should be fine-grained to a minimal unit of describability (the thing being documented). The practice provides numerous benefits to…
💩4👍2
#prog #rust #article
Control flow patterns in Rust
Не слишком информативный пост для опытных Rust-программистов, но увидел любопытный паттерн для обхода отсутствия let-chains.
Именно, вместо
Control flow patterns in Rust
Не слишком информативный пост для опытных Rust-программистов, но увидел любопытный паттерн для обхода отсутствия let-chains.
Именно, вместо
let deadline = if let Some(settings) = self.settings {
if let Some(deadline) = settings.deadline {
if settings.deadline_override && deadline > 0 {
deadline
} else {
self.default_deadline
}
} else {
self.default_deadline
}
} else {
self.default_deadline
};
можно воспользоваться labeled block break и написатьlet deadline = 'done: {
if let Some(settings) = self.settings {
if let Some(deadline) = settings.deadline {
if settings.deadline_override && deadline > 0 {
break 'done deadline;
}
}
}
self.default_deadline
};symbolica.io
Symbolica – Control flow patterns in Rust
👍8💩6🤯2😍1
Блог*
#prog #rust #article Control flow patterns in Rust Не слишком информативный пост для опытных Rust-программистов, но увидел любопытный паттерн для обхода отсутствия let-chains. Именно, вместо let deadline = if let Some(settings) = self.settings { if…
А ещё там есть пример для эмуляции for-else из Python, но этот пример лишь лишний раз укрепил меня во мнении, что эта языковая конструкция попросту не требуется в языке с достаточно продвинутыми итераторами.
К примеру, оригинал на Python:
К примеру, оригинал на Python:
items = [3,5,7,11,13,17]
item = 19
location = None
for i, x in enumerate(items):
if x == item:
location = i
break
else:
# break was not triggered
location = len(items)
items.append(item)
и его переделка на Rust, предложенная автором:let mut items = vec![3,5,7,11,13,17];
let item = 19;
let location = 'find_item: {
for (i, x) in items.iter().enumerate() {
if *x == item {
break 'find_item i;
}
}
// only reached when not breaking
items.push(item);
items.len() - 1
};
На мой взгляд, с использованием итераторов Rust это можно записать более кратко без потери выразительности:let location = match items
.iter()
.position(|&x| x == item)
{
Some(idx) => idx,
None => {
let idx = items.len();
items.push(item);
idx
}
};👍8💩3❤🔥1🔥1
Fun fact: std::derived_from из C++ не имеет никакого отношения к derive-макросам из Rust
💩6🥴3
Forwarded from Ебучий случай
В последние 2 года регулярно слышу "ой, ну я не верующий, я не могу есть куличи".
Да ну вы чего!! Вас забуллила бабка у церкви или в твиттере кто-то предъявил? Раньше не было такой ерунды.
Не позволяйте никому встать между вами и вкусной сдобой с цукатами! Мы живем в прекрасное время, когда от любого праздника, традиции или обряда можно брать только ту часть, которая вам нравится, и не погружаться в детали, если не хочется. Единственная уместная куличиковая полиция - это та, которая ходит и раздает всем куличи, а не запрещает их есть.
Всем вкусных булок и нарядных яиц!
Да ну вы чего!! Вас забуллила бабка у церкви или в твиттере кто-то предъявил? Раньше не было такой ерунды.
Не позволяйте никому встать между вами и вкусной сдобой с цукатами! Мы живем в прекрасное время, когда от любого праздника, традиции или обряда можно брать только ту часть, которая вам нравится, и не погружаться в детали, если не хочется. Единственная уместная куличиковая полиция - это та, которая ходит и раздает всем куличи, а не запрещает их есть.
Всем вкусных булок и нарядных яиц!
👍24🤡4❤2💩1
Это, конечно, нужно быть большим оригиналом, чтобы инсценировать свои смерть, воскрешение и вознесение на небо только ради того, чтобы избежать призыва.
😁8💩3🤡2
#prog #rust #article
Writing a Fast C# Code-Search Tool in Rust
Экскурс в использование зависимостей в Rust /hj
В итоге, впрочем, инструмент вышел на порядок быстрее Roslyn.
Writing a Fast C# Code-Search Tool in Rust
Экскурс в использование зависимостей в Rust /hj
В итоге, впрочем, инструмент вышел на порядок быстрее Roslyn.
John Austin
Writing a Fast C# Code-Search Tool in Rust — John Austin
When I began learning Rust, I had several expectations. I figured that I would be a little less productive writing code, in exchange for memory safety and C-like performance. What I did not expect, was that I would actually be more productive writing…
💩1
А вы тоже постоянно покупаете новые резинки и заколки для волос, которыми потом не пользуетесь, или вы нормальные?
🥴13😁5💩2🤡1
#prog #rust #article
A formulation for scoped tasks in Rust
Или о том, почему асинхронный аналог thread::scope невозможен в текущем языке
A formulation for scoped tasks in Rust
Или о том, почему асинхронный аналог thread::scope невозможен в текущем языке
Tyler Mandry
A formulation for scoped tasks in Rust
For just about as long as I’ve been working on async Rust, the topic of scoped tasks has come up. These are async tasks that borrow from their environment, and they would come in handy in a lot of situations.
Last year the standard library stabilized thread::scope…
Last year the standard library stabilized thread::scope…
💩1