Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
www.afloat.boats
...fn end_player_turn(&mut self) { self.player_turn = match self.player_turn { Player::Red => Player::Black, Player::Black => Player::Red, } } // 2. pub fn select_col(&mut self, col_idx: u8) -> bool { // board update logic will go here self.end_player_turn(); } } 1. end_player_turnThe end_player_turn function...
Rust Walkthroughs 2025-10-29 ~7 min read
uwheel.rs
...if let Some(rewritten) = self.try_rewrite(&plan) { Ok(Transformed::yes(rewritten)) } else { Ok(Transformed::no(plan)) } } Internally, the rewriter looks for temporal patterns and aggregation functions that match the stored wheel indices. If there is a match then the target wheel is queried and the aggregate result gets stored...
Observations/Thoughts 2024-08-21 ~4 min read
leshow.github.io
...Rust includes a way to pattern match on enum variants with the match keyword. If you haven’t used a language with robust pattern matching before, it’s really a pleasure to use. fn plus(a: Option<usize>) -> Option<usize> { match a { Some(v) => Some(v + 1), None => None } } This...
News & Blog Posts 2020-02-18 ~20 min read
gfx-rs.github.io
...We were especially interested in finding projects matching the following criteria: Open-source: allows us to easily debug issues and add or modify existing macOS window and surface support Already using Vulkan for rendering: allows us to simply load gfx-portability on macOS in place of a Vulkan driver on...
News & Blog Posts 2018-09-04 ~3 min read
mhamza.dev
...Now, imagine you want to call this function from JavaScript, passing in an object that matches the structure of Data: do_work({ key_id: 'key_id', name: 'name', }); Unfortunately, this pattern is not currently possible with wasm-bindgen due to the restrictions it imposes. It requires the object passed to...
Project/Tooling Updates 2023-06-21 ~3 min read
hugopeters.me
...Plug<B> + Generic1; } impl<A> Functor for Option<A> { fn fmap<B>(&self, f: &dyn Fn(&<Self as Generic1>::I) -> B) -> <Self as Plug<B>>::R { // Apply the function over the contained value, if there is one match self { None => None, Some(v) => Some(f(v)), } } } Applicative This one is...
Rust Walkthroughs 2021-12-08 ~5 min read
www.lpalmieri.com
...web::Data<Secret<String>>, // No longer returning a `Result<HttpResponse, LoginError>`! ) -> HttpResponse { // [...] match validate_credentials(credentials, &pool).await { Ok(user_id) => { tracing::Span::current() .record("user_id", &tracing::field::display(&user_id)); HttpResponse::SeeOther() .insert_header((LOCATION, "/")) .finish() } Err(e) => { let e = match e { AuthError::InvalidCredentials(_) => LoginError::AuthError(e.into...
Rust Walkthroughs 2022-01-05 ~92 min read
kyle.space
...u16) -> u8 { match addr { // RAM (mirrored every 0x0800 bytes) 0x0000..=0x07FF => { let ram_offset = (addr as usize) % self.ram.len(); self.ram[ram_offset] } // PRG-ROM (mirrored to fill all 32 KiB) 0x8000..=0xFFFF => { let rom_len = self.rom.prg_rom.len(); let rom_offset = (addr as usize - 0x8000) % rom...
News & Blog Posts 2019-10-22 ~29 min read
sjames.github.io
...Sized + ASN1GenType, { type Target = T; fn deref(&self) -> &T { match self.0 { AllocatedData::Asn1CodecAllocated(p) => unsafe { &*p as &T }, AllocatedData::RustAllocated(p) => unsafe { &*p as &T }, } } } impl<T> DerefMut for ASNBox<T> where T: Sized + ASN1GenType, { fn deref_mut(&mut self) -> &mut T { match self.0 { AllocatedData::Asn1CodecAllocated(p) => unsafe...
News & Blog Posts 2020-05-12 ~18 min read
johns.codes
...match readline { Ok(line) => { match SqlQuery::parse_from_raw(line.as_ref()) { Ok(q) => println!("{q:?}"), Err(e) => eprintln!("{e:?}"), } } Now we can finally type some stuff and have different things come back.>> select col1 from foo; (LocatedSpan { offset: 21, line: 1, fragment: "", extra: () }, Select(SelectStatement { tables: ["foo"], fields: ["col1...
Rust Walkthroughs 2023-01-04 ~14 min read
rust-lang-nursery.github.io
...The wav feature compiles in only the WAV reader; enable the features matching the formats you need. Play an audio file [![rodio-badge]][rodio] [![cat-multimedia-badge]][cat-multimedia] Playing a notification sound means opening an output device and handing it a decoded source. [rodio][rodio] does both. DeviceSinkBuilder::open...
The Rust Cookbook Book 2024-01-01 ~1 min read
www.ralfj.de
...The same also happens with match statements: let ptr = std::ptr::null::<i32>(); match *ptr { _ => "happy" } // This is fine! match *ptr { _val => "not happy" } // This is UB. The scrutinee of a match expression is a place expression, and if the pattern is _ then a value is never constructed. However, when...
Observations/Thoughts 2024-08-21 ~11 min read
bheisler.github.io
...u64) -> u64 { match n { 0 => 1, 1 => 1, n => fibonacci(n-1) + fibonacci(n-2), } } fn criterion_benchmark(c: &mut Criterion) { c.bench_function("fib 20", |b| b.iter(|| fibonacci(20))); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches); Finally, run this benchmark with cargo bench. You should see output...
News & Blog Posts 2018-01-16 ~5 min read
smallcultfollowing.com
...In particular, types that implement Debug will prefer impl I.Another way to express the rule is to say that impls can specialize one another in two ways:if the types matched by one impl are a subset of the other, ignoring where clauses altogether;otherwise, if the types matched...
Blog Posts 2016-10-25 ~17 min read
jyn.dev
...Enums without pattern matching are very painful to work with and pattern matching without enums has very odd semantics Result and Iterators are impossible to implement without generics (or duck-typing, which I think of as type-erased generics) Send/Sync, and the preconditions to println, are impossible to encode...
Observations/Thoughts 2025-08-27 ~7 min read
doc.rust-lang.org
...They’re faster than you might think!) We’ve already covered some other Rust features, such as pattern matching and enums, that are also influenced by the functional style. Because mastering closures and iterators is an important part of writing fast, idiomatic, Rust code, we’ll devote this entire chapter...
The Rust Programming Language Book 2024-02-01 ~1 min read
www.ncameron.org
...The first rename matches, so we rename to x[4](), then we add the two marks: x[4](1, 2). Neither of the later two renames match, so we end up with the resolved name x[4]. Now consider y[2]. In this case the first rename does not match...
News & Blog Posts 2015-11-09 ~11 min read
doc.rust-lang.org
...AliasedResult<i32>) { match result { Ok(n) => println!("n is {}", n), Err(e) => println!("Error: {}", e), } } fn main() { print(multiply("10", "2")); print(multiply("t", "2")); } See also: io::Result
Rust by Example Book 2024-01-01 ~1 min read
www.jessestuart.ca
...Next up was considering using an enum with all the possible trait implementors, but then I’d have to match the concrete type for every operation which very quickly gets too complex. The use case involved composing all the implementors of the aforementioned trait to act as a single implementor...
Observations/Thoughts 2025-10-15 ~5 min read
rust-analyzer.github.io
...t responsible for variant pattern completions. #8028 prepare for returning parents in the "Locate parent module" command. #8039 use SmallVec for Substs. #8046 add match vs. if let …​ else entry to the style guide. #8034 implement Crate::transitive_reverse_dependencies. #8042 (first contribution) add rustc-perf version to the metrics...
Project/Tooling Updates 2021-03-24 ~1 min read
"Rust-based Python type checkers are like buses - you wait ages for one and then two come along at once."

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, research, crates, and Rust API documentation. These operators give you finer control — click an example to try it.

Find pages containing all your words. Pages where the words appear together rank higher.
Quote part of your query to keep those words together as an exact phrase within a larger search.
Wrap the whole query in quotes for a verbatim search that matches text exactly, punctuation and all — perfect for Rust syntax. Needs at least 3 characters.
Limit results to a single site. Works on its own () too. One site: per search.

Use the tabs and filters above the results to narrow by content type, publication year, and sort order.