Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
rust-lang.github.io
...Rust already allows similar syntax for destructuring in pattern matches: a pattern match can use SomeStruct { field1, field2 } => ... to match field1 and field2 into values with the same names. This RFC introduces symmetrical syntax for initializers. A family of related structures will often use the same field name for a...
RFC 1682 RFC 2016-07-18 ~6 min read
dystroy.org
...while !(maze.is_won() || maze.is_lost()) { renderer.write(w, &maze)?; w.flush()?; let e = event::read(); match e { Ok(Event::Key(key_event)) => match key_event.into() { key!(q) | key!(ctrl-c) | key!(ctrl-q) => { return Ok(()); } key!(up) => maze.try_move_up(), key!(right) => maze.try_move_right...
Observations/Thoughts 2022-08-03 ~3 min read
www.joshmcguigan.com
...In a larger program this type of match pattern would get repeated many times, and this is exactly why the ? operator was introduced. use std::fs::File; fn main() { let file : File = match File::open("filename") { Ok(file) => file, Err(e) => { eprintln!("Error: {}", e); std::process::exit(9); } }; // do something...
News & Blog Posts 2019-02-12 ~5 min read
crates.io
...Example use urlpattern::UrlPattern; use urlpattern::UrlPatternInit; use urlpattern::UrlPatternMatchInput; fn main() { // Create the UrlPattern to match against. let init = UrlPatternInit { pathname: Some("/users/:id".to_owned()), ..Default::default() }; let pattern = <UrlPattern>::parse(init, Default::default()).unwrap(); // Match the pattern against a URL. let url = "https://example.com/users/123...
Crate v0.6.0 2026-02-12
rust-analyzer.github.io
#15118 (first contribution) follow raw pointers in autoderef chain when resolving methods with custom receiver. #15235 (first contribution) don’t insert semicolon when extracting match arm. #15226 make Expand glob import work on enum imports. #15211 support GATs in bounds for associated types. #15223 don’t show unresolved-field diagnostic...
Project/Tooling Updates 2023-07-12 ~1 min read
danielkeep.github.io
...You can only match against literals and grammar constructs which can be captured by macro_rules!. You cannot match unbalanced groups. It is important, however, to keep the macro recursion limit in mind. macro_rules! does not have any form of tail recursion elimination or optimisation. It is recommended that...
Rust Compiler Performance Triage 2022-04-06 ~1 min read
dev.to
...Vec<&str> = tokens[0].splitn(3, "").collect(); let choice = bookmark_tokens[2].to_string().parse::<usize>(); match choice { Ok(choice) => { let bookmark_pos = choice - 1; if bookmark_pos < locations.len() { let listing = locations[bookmark_pos].clone(); let data = visit(&listing.domain, &listing.port, &listing.file_path); match data { Ok(data...
Rust Walkthroughs 2020-11-04 ~11 min read
zed.dev
...let mut matching_paths = matching_paths_rx .take(MAX_SEARCH_RESULT_FILES + 1) .collect::<Vec<_>>() .await; // ... then loops over the filepaths in chunks of 64... for matching_paths_chunk in matching_paths.chunks(64) { let mut chunk_results = Vec::new(); for matching_path in matching_paths_chunk { // .... opens each file...
Rust Walkthroughs 2024-04-10 ~12 min read
blog.jeffsmits.net
...Within a pattern match a variable may occur multiple times, and can be bound by one of those occurrences and matched against in the other places. The bug in the original attempt at implementing pattern matching was that bindings were directly mutated during pattern matching. So the pattern matching code...
News & Blog Posts 2017-08-08 ~23 min read
doc.rust-lang.org
...i32) -> i32 { match self { Self::Add => x + y, Self::Subtract => x - y, } } } To learn more about enums and type aliases, you can read the stabilization report from when this feature was stabilized into Rust. See also: match, fn, and String, "Type alias enum variants" RFC
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
...Parse(ParseIntError), } impl fmt::Display for DoubleError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { DoubleError::EmptyVec => write!(f, "please use a vector with at least one element"), // The wrapped error contains additional information and is available // via the source() method. DoubleError::Parse(..) => write!(f, "the provided...
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
pub fn strip_prefix<P>(&self, prefix: P) -> Option<&str>
...Unlike trim_start_matches, this method removes the prefix exactly once. If the string does not start with prefix, returns None. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Examples assert_eq!("foo:bar".strip_prefix...
method core Stable since 1.45.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn strip_suffix<P>(&self, suffix: P) -> Option<&str>
...Unlike trim_end_matches, this method removes the suffix exactly once. If the string does not end with suffix, returns None. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Examples assert_eq!("bar:foo".strip_suffix...
method core Stable since 1.45.0 Version 1.100.0-nightly
www.youtube.com
...finally it's just matches the inch keywords if you want to distinguish it from inter isn't right because it matches both rules so when there is an ambiguity lexical analyzers like rest legs but also lex will also will always try to match the longest input as possible...
Video 2017-01-03
doc.rust-lang.org
pub struct RSplitN<'a, T, P>
RSplitN — An iterator over subslices separated by elements that match a predicate function, limited to a given number of splits, starting from the end of the slice. This struct is created by the rsplitn method on slices. Example let slice = [10, 40, 30, 20, 60, 50]; let mut iter = slice...
struct core Stable since 1.0.0 Version 1.100.0-nightly
rust-analyzer.github.io
...members". #9700 remove the legacy macro scoping hack. #9722 refine the targets of the "Extract function" assist. #9728 attach comma token to MATCH_ARM instead of MATCH_ARM_LIST. #9742 fix hover range for derive inputs. #9739 favor dereffed types in "Generate function" assist. #9747 wrap inner tail expressions in...
Project/Tooling Updates 2021-08-04 ~1 min read
doc.rust-lang.org
...Send>) | | &Type&mut Type | reference types | | *mut Type*const Type | raw pointer types | | fn(…) -> Type | function pointer types | | _ | inferred type, inferred const | | '_ | placeholder lifetime | | ! | never type | Patterns [Patterns] are used to match values. | Pattern | Use | |-----------------------------------|-----| | "foo", 'a', 123, 2.4, … | literal patterns | | ident | identifier patterns | | _ | wildcard pattern | | .. | rest pattern | | a...
The Rust Reference Book 2024-01-01 ~9 min read
blog.scottlogic.com
...Rust’s pattern matching, with ranges, is an ideal tool for implementing this. Here’s an example that uses range matching to implement the jump instruction: fn process_opcode(&mut self, opcode: u16) { match (opcode) { 0x1000 ... 0x1FFF => self.pc = opcode & 0x0FFF, // match other ranges to process other opcodes. _ => () } } However, not...
News & Blog Posts 2017-12-19 ~12 min read
hackeryarn.com
...A macro has to always take and produce a token tree, and that's exactly what our match arms represent. As far as macros care, all of the tree operators are interchangeable. So we could write our match arm as: { from $db:ident select $( $field:ident ),+ where $($test_field:ident...
Rust Walkthroughs 2025-10-08 ~6 min read
bluss.github.io
...impl List { fn walk_the_list(&mut self) { let mut current = self; loop { match current.next { None => return, Some(ref mut inner) => current = inner, } } } } Looks good? Rustc disagrees! (compile in the playground) error: cannot borrow `current.next.0` as mutable more than once at a time [E0499] Some(ref mut...
News & Blog Posts 2015-10-12 ~2 min read
"Rust does best when we're ambitious"

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.