Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
fasterthanli.me
...non-exhaustive patterns: `5u16..=std::u16::MAX` not covered --> src/lib.rs:17:15 | 17 | match x { | ^ pattern `5u16..=std::u16::MAX` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms To deal with that possibility, we could return an...
News & Blog Posts 2020-02-25 ~29 min read
doc.rust-lang.org
pub fn into_utf8_lossy(self) -> String
...Vec<u8> = b"Hello \xF0\x90\x80World".into(); let (output, had_invalid_utf8) = match String::from_utf8(input) { Ok(output) => (output, false), Err(error) => { // The bytes were not valid UTF-8, but we can still recover a string. (error.into_utf8_lossy(), true) } }; assert_eq!(String::from("Hello �World"), output...
method alloc Stable since 1.100.0 Version 1.100.0-nightly
blog.lilyf.org
...swapped_context }; let cloned = py_context.clone(); let content = self.func.call1( py, (cloned,)?; let inner_context = match Arc::try_unwrap( py_context.context) { Ok(inner_context) => { inner_context } Err(_) => todo!(), }; let _ = std::mem::replace( context, inner_context); Ok(content.to_string()) } } } This works great when Python doesn’t keep...
Rust Walkthroughs 2025-09-03 ~5 min read
docs.rs
...proc_macro::TokenStream) -> proc_macro::TokenStream { match my_macro(tokens.into()) { Ok(tokens) => tokens.into(), Err(diag) => diag.emit_as_expr_tokens().into() } } This does the right thing on nightly or stable. Caveats On stable, due to limitations, any top-level, non-error diagnostics are emitted as errors. This will...
Crate v0.10.1 2023-07-10
doc.rust-lang.org
pub fn splitn<P>(&self, n: usize, pat: P) -> SplitN<'_, P>
...The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Iterator behavior The returned iterator will not be double ended, because it is not efficient to support. If the pattern allows a reverse search, the rsplitn method can...
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn expect(self, msg: &str) -> T
...Instead, prefer to use pattern matching and handle the Err case explicitly, or call unwrap_or, unwrap_or_else, or unwrap_or_default. Panics Panics if the value is an Err, with a panic message including the passed message, and the content of the Err. Examples let x: Result<u32...
method core Stable since 1.4.0 Version 1.100.0-nightly
trifectatech.org
...allow unaligned reads in longest_match wasm: SIMD adler32 wasm: SIMD slide_hash wasm: use wider loads/stores in copy_match wasm: SIMD compare256 Decompression implementationspeedup (wall time) baseline-41.1% miniz-oxide-54.9% zlib-ng-25.3% Our optimizations made our implementation over 40% faster; we're now...
Observations/Thoughts 2024-11-20 ~3 min read
noyez.gitlab.io
...Deserializer<'de> { match MacOrU64::deserialize(deserializer)? { MacOrU64::U64(v) => { Ok(v) } MacOrU64::Mac(v) => { mac_addr_as_u64(&v).ok_or(serde::de::Error::custom("Can't parse MAC address")) } } } Note the #[serde(untagged)] attribute which makes the serialized JSON an anonymous object. See the serde documentation for serge’s...
News & Blog Posts 2018-09-04 ~3 min read
docs.rs
...for inner_pair in pair.into_inner() { match inner_pair.as_rule() { Rule::alpha => println!("Letter: {}", inner_pair.as_str()), Rule::digit => println!("Digit: {}", inner_pair.as_str()), _ => unreachable!() }; } } } This produces the following output: Rule: ident Span: Span { start: 0, end: 2 } Text: a1 Letter: a Digit: 1 Rule: ident...
Crate v2.9.0 2026-08-13
219design.com
...Example match block!(bnrg.with_spi(&mut spi, |c| c.read())) { Ok(p) => { let hci::host::uart::Packet::Event(e) = p; match e { bluetooth_hci::event::Event::ConnectionComplete(params) => { // handle the new connection } bluetooth_hci::event::Event::Vendor( bluenrg::event::BlueNRGEvent::HalInitialized(reason), ) => { // handle the BlueNRG chip reset } _ => (), } } Err(e...
News & Blog Posts 2018-10-09 ~12 min read
doc.rust-lang.org
...missing fragment specifier } fn main() { foo!(); } Calling the macro with arguments that would match a rule with a missing specifier (e.g., foo!($name)) was a hard error in all editions. However, simply defining a macro with missing fragment specifiers was not, though we did add a lint in Rust...
The Rust Edition Guide Book 2024-01-01 ~1 min read
rust.code-maven.com
...For example by using match and handling the Ok and Err cases separately. Inside the prompt function we don't have any explicit error handling. We just added ? at the end of the calls that might fail. This means if either of those calls fail, the prompt function immediately returns...
Miscellaneous 2024-01-03 ~3 min read
docs.rs
...for inner_pair in pair.into_inner() { match inner_pair.as_rule() { Rule::alpha => println!("Letter: {}", inner_pair.as_str()), Rule::digit => println!("Digit: {}", inner_pair.as_str()), _ => unreachable!() }; } } } This produces the following output: Rule: ident Span: Span { start: 0, end: 2 } Text: a1 Letter: a Digit: 1 Rule: ident...
Crate v2.9.0 2026-08-13
blog.japaric.io
...a task token whose type must match the interrupt field of the declaration, a priority token whose type must match the priority field of the declaration, and a threshold token whose type must match the level of the priority token. The priority and threshold tokens we have already seen. The...
News & Blog Posts 2017-05-09 ~37 min read
docs.rs
...for inner_pair in pair.into_inner() { match inner_pair.as_rule() { Rule::alpha => println!("Letter: {}", inner_pair.as_str()), Rule::digit => println!("Digit: {}", inner_pair.as_str()), _ => unreachable!() }; } } } This produces the following output: Rule: ident Span: Span { start: 0, end: 2 } Text: a1 Letter: a Digit: 1 Rule: ident...
Crate v2.9.0 2026-08-13
doc.rust-lang.org
pub fn rsplitn<P>(&self, n: usize, pat: P) -> RSplitN<'_, P>
...The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Iterator behavior The returned iterator will not be double ended, because it is not efficient to support. For splitting from the front, the splitn method can be used...
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()>
...use std::io::{self, Read}; use std::net::TcpStream; let mut stream = TcpStream::connect("127.0.0.1:7878") .expect("Couldn't connect to the server..."); stream.set_nonblocking(true).expect("set_nonblocking should succeed"); let mut buf = vec![]; loop { match stream.read_to_end(&mut buf) { Ok(_) => break, Err...
method std Stable since 1.9.0 Version 1.100.0-nightly
docs.rs
...for inner_pair in pair.into_inner() { match inner_pair.as_rule() { Rule::alpha => println!("Letter: {}", inner_pair.as_str()), Rule::digit => println!("Digit: {}", inner_pair.as_str()), _ => unreachable!() }; } } } This produces the following output: Rule: ident Span: Span { start: 0, end: 2 } Text: a1 Letter: a Digit: 1 Rule: ident...
Crate v2.9.0 2026-08-13
nadrieril.github.io
...let tmp = x.method(); something(&tmp.field); This is exactly what we need for postfix macros: <expr>.macro!() would become (using a match to make the temporary lifetimes work as they should 🤞): match <expr> { place p => macro!(p), } This would have the effect I propose above: any side-effects...
Observations/Thoughts 2025-12-10 ~8 min read
rustacean-station.org
...hello@rustacean-station.org Timestamps & referenced resources 03:05 - RPIT lifetime capture rules 08:00 - let chains in if and while if let temporary scope Mara’s post on “super let” Tail expression temporary scope 19:15 - Match ergonomics reservations 24:49 - Unsafe extern blocks 29:15 - Unsafe attributes 32...
Observations/Thoughts 2026-02-04 ~1 min read
"I feel like I'm doing something wrong because I'm programming faster and nothing has gone wrong yet"

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.