Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
github.com
...Adding this hint to enums will force downstream crates to add a wildcard arm to `match` statements, ensuring that adding new variants is not a breaking change. Adding this hint to structs or enum variants will prevent downstream crates from constructing or exhaustively matching, to ensure that adding new fields...
RFC 2008 RFC 2017-05-24 ~12 min read
doc.rust-lang.org
...rust 1.65 πŸ›ˆ you can target specific edition by compiling like this rustc --edition=2021 main.rs With let-else, a refutable pattern can match and bind variables in the surrounding scope like a normal let, or else diverge (e.g. break, return, panic!) when the pattern doesn't...
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<'_, T, F>
slice::rsplit_mut β€” Returns an iterator over mutable subslices separated by elements that match pred, starting at the end of the slice and working backwards. The matched element is not contained in the subslices. Examples let mut v = [100, 400, 300, 200, 600, 500]; let mut count = 0; for group...
method core Stable since 1.27.0 Version 1.100.0-nightly
doc.rust-lang.org
...In the example below, the straightforward match statement leads to code that is overall more cumbersome. use std::num::ParseIntError; // With the return type rewritten, we use pattern matching without `unwrap()`. fn multiply(first_number_str: &str, second_number_str: &str) -> Result<i32, ParseIntError> { match first_number_str.parse::<i32...
Rust by Example Book 2024-01-01 ~1 min read
dev.to
...When you press Enter, matching lines go to stdout. Non-TTY stdout skips the TUI entirely, so it composes in pipelines. The --json <PATH> flag extracts a specific field from JSONL records before matching β€” useful when you want to filter by message content without the pattern accidentally matching timestamps or...
Project/Tooling Updates 2026-05-27 ~4 min read
doc.rust-lang.org
pub fn splitn<F>(&self, n: usize, pred: F) -> SplitN<'_, T, F>
slice::splitn β€” Returns an iterator over subslices separated by elements that match pred, limited to returning at most n items. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice. Examples Print the slice split once by numbers...
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn splitn_mut<F>(&mut self, n: usize, pred: F) -> SplitNMut<'_, T, F>
slice::splitn_mut β€” Returns an iterator over mutable subslices separated by elements that match pred, limited to returning at most n items. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice. Examples let mut v = [10, 40...
method core Stable since 1.0.0 Version 1.100.0-nightly
hovinen.me
...I have extended the shorthand syntax for matching against containers in the verify_that! macro and friends to other macro-based matchers, such as matches_pattern!. So one can write things like: matches_pattern!(MyStruct { a_vec: [eq(1), eq(2), eq(3)] }) The type alias Result is now called...
Project/Tooling Updates 2026-07-01 ~12 min read
audunhalland.github.io
...The macro is called matching!: matching!(1, "2", 3.0) It basically expands to a pattern match on the arguments, along with useful diagnostics in the case of an unsuccessful match. Every string literal is matched using AsRef<str>. The input matching was not the hardest part to design. Now...
Rust Walkthroughs 2023-04-12 ~14 min read
doc.rust-lang.org
Guards A match guard can be added to filter the arm. #[allow(dead_code)] enum Temperature { Celsius(i32), Fahrenheit(i32), } fn main() { let temperature = Temperature::Celsius(35); // ^ TODO try different values for `temperature` match temperature { Temperature::Celsius(t) if t > 30 => println!("{}C is above 30 Celsius", t), // The `if...
Rust by Example Book 2024-01-01 ~1 min read
conradludgate.com
...Notice we no longer can use &self.xxx in our field args, instead we need to use the values from the match arms. Pattern matching So, a neat thing of rust is that you can use patterns outside of match statements. Take a look at this Now, wouldn't you...
Rust Walkthroughs 2022-06-08 ~4 min read
doc.rust-lang.org
pub fn rmatches<P>(&self, pat: P) -> RMatches<'_, P>
str::rmatches β€” Returns an iterator over the disjoint matches of a pattern within this string slice, yielded in reverse order. 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 requires that the...
method core Stable since 1.2.0 Version 1.100.0-nightly
docs.rs
...assert!(specific.eval(|pred| { match pred { Predicate::Target(tp) => tp.matches(x86_win), Predicate::TargetFeature(feat) => avail_target_feats.contains(feat), Predicate::Feature(feat) => *feat == "cool_thing", _ => false, } })); // This will *not* satisfy the vendor predicate assert!(!specific.eval(|pred| { match pred { Predicate::Target(tp) => tp.matches(uwp_win), Predicate::TargetFeature...
Crate v0.20.11 2026-11-13
doc.rust-lang.org
pub fn rsplitn_mut<F>(&mut self, n: usize, pred: F) -> RSplitNMut<'_, T, F>
slice::rsplitn_mut β€” Returns an iterator over subslices separated by elements that match pred limited to returning at most n items. This starts at the end of the slice and works backwards. The matched element is not contained in the subslices. The last element returned, if any, will contain the...
method core Stable since 1.0.0 Version 1.100.0-nightly
rust-lang.github.io
...Pattern matching Unsafe code may pattern match on union fields, using the same syntax as a struct, without the requirement to mention every field of the union in a match or use ..: fn f(u: MyUnion) { unsafe { match u { MyUnion { f1: 10 } => { println!("ten"); } MyUnion { f2 } => { println!("{}", f2); } } } } Matching a...
RFC 1444 RFC 2015-12-29 ~12 min read
doc.rust-lang.org
pub fn rsplitn<F>(&self, n: usize, pred: F) -> RSplitN<'_, T, F>
slice::rsplitn β€” Returns an iterator over subslices separated by elements that match pred limited to returning at most n items. This starts at the end of the slice and works backwards. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder...
method core Stable since 1.0.0 Version 1.100.0-nightly
llogiq.github.io
...FnOnce(PathElems) -> T function, which I will use to match the path. Since I suspect this is something we intend to do in other lints, too, I’m going to put this matching function in utils.rs as fn match_def_path(cx: Context, def_id: DefId, path: &[&str]) -> bool...
Notable Links 2015-06-07 ~15 min read
kivooeo.github.io
...Some(vec![]), }; let x = Some(42); match x { Some(x) if let A { related_points, .. } = a && let Some(points) = related_points => points.len() _ => 1, }; } So, currently you are forced to write a block like this match x { Some(x) => { if let A { related_points, .. } = a && let Some(points) = related_points...
Observations/Thoughts 2026-01-28 ~10 min read
doc.rust-lang.org
pub fn rfind<P>(&self, pat: P) -> Option<usize>
str::rfind β€” Returns the byte index for the first character of the last match of the pattern in this string slice. Returns None if the pattern doesn't match. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character...
method core Stable since 1.0.0 Version 1.100.0-nightly
matklad.github.io
...char) -> ((), u8) { match op { '+' | '-' => ((), 5), _ => panic!("bad op: {:?}", op), } } fn postfix_binding_power(op: char) -> Option<(u8, ())> { let res = match op { '!' => (7, ()), _ => return None, }; Some(res) } fn infix_binding_power(op: char) -> (u8, u8) { match op { '+' | '-' => (1, 2), '*' | '/' => (3, 4), '.' => (10, 9), _ => panic!("bad op: {:?}"), } } #[test] fn tests() { let s...
News & Blog Posts 2020-04-14 ~22 min read
"once you can walk barefoot (C), it’s easy to learn to walk with shoes (go) but it will take time to learn to ride a bike (rust)"

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.
Put ! first to open the top result immediately. Quote the whole query for a literal leading bang, as in '!Send'. Bangs elsewhere, such as println!, stay literal. Browser and launcher shortcuts can invoke this directly. See search integrations.
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.