Daily Rust (@rustoftheday) header
Daily Rust (@rustoftheday) profile picture

Daily tips & tricks for Rust 🦀 programming. Following back all accounts with 🦀 or 🐪 in their profile.

Joined November 2023
Photo by Daily Rust (@rustoftheday)Photo by Daily Rust (@rustoftheday)Photo by Daily Rust (@rustoftheday)Photo by Daily Rust (@rustoftheday)Photo by Daily Rust (@rustoftheday)Photo by Daily Rust (@rustoftheday)Photo by Daily Rust (@rustoftheday)Photo by Daily Rust (@rustoftheday)Photo by Daily Rust (@rustoftheday)
Want true pub-sub semantics in Rust? The Bus crate gives you SP→MC broadcast semantics. Crossbeam’s MPSC supports multiple consumers, but it round-robins messages, not exactly what you want for fan-out. crates.io/crates/bus
1
2
1
42
3,125
#119 (contd.) - imposes runtime cost by stack walking - encourages using panic for control flow - many APIs are not unwind-safe - cannot catch "fatal" errors such as out-of-memory
9
781
🦀 #Rust Tip #119: Some folks suggest using std::panic::catch_unwind as a solution to the recent unwrap() panic that stopped the internet. In my opinion this is an anti-pattern, some thoughts: - bypasses memory safety constraints (e.g., panic in unsafe block)
9
47
4,286
Daily Rust retweeted
You generally want a Clippy linter like this one in your Rust production code
🦀 Bad news everyone - unwrap() is the reason behind cloudflare outage >The FL2 Rust code that makes the check and was the source of the unhandled error is shown below blog.cloudflare.com/18-novem…
27
42
8
1,065
90,460
Don't use unwrap() in your production code, boys and girls! 😃
Cloudflare generated many millions of HTTP 5XX responses today. They were triggered because code in a core proxy called .unwrap() on a Result for an operation that was expected to never fail.
28
21
4
385
33,081
Animate anything with Rust 🦀 🌀 KramaFrame — A simple, generic, and flexible keyframe animation library. ⚡ Manage multiple animations, apply easing functions, and map progress to any range. 🐁 Includes a terminal demo w/ @ratatui_rs ⭐ GitHub: github.com/CosmoBunny/kramaf… #rustlang #animation #library #programming #terminal #ratatui #tui
6
84
8,584
This is gold if you're using async Rust 💯 🌀 channels-console — A TUI dashboard for inspecting std/tokio/futures/crossbeam channels. 📊 Watch messages, queue depth, throughput & memory usage live. 🦀 Written in Rust & built with @ratatui_rs ⭐ GitHub: github.com/pawurb/channels-c… #rustlang #ratatui #tui #async #concurrency #tokio #debugging
8
44
2
419
22,412
🦀 #Rust Tip #118: Result::and_then lets us chain operations that return Result, bypassing nested pattern matching. Although the ? operator often accomplishes the same, and_then allows us to remain in a more functional "combinator style".
12
13
1
167
11,571
Not sure I follow 100%, if statements don't need round parens, for example. Also, try a C++ closure auto add = [&sum](int v){ sum += v; }; ampersand and all types of possible parens Rust: let mut add = |v| { total += v; };
14
🥵
7
16
1
169
5,739
IMHO the killer features of Rust are the high-level abstractions baked in at "Zero Cost", with much better ergonomics (==readability) than equivalent features e.g., in C++. Memory safety is just an additional safeguard the compiler provides.
5
474