Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
github.com
## Summary [summary]: #summary Enable `if` and `match` during const evaluation and make them evaluate lazily. In short, this will allow `if x < y { y - x } else { x - y }` even though the else branch would emit an overflow error for unsigned types if `x < y`. ## Motivation [motivation]: #motivation Conditions in constants...
RFC 2342 RFC 2018-01-11 ~3 min read
thesquareplanet.com
...You may be tempted to write code like this let mut v = foo(); match v { Enum::Bar(ref mut x) => { x += 1; }, Enum::Baz(ref mut y) => { y -= 1; }, _ => (), // needed to make pattern exhaustive }; v But match can make this much nicer: match foo() { Enum::Bar(x) => Enum::Bar(x...
Blog Posts 2016-10-25 ~8 min read
bal-e.org
...you need to match the input (a, b) against the match arms in foo (“parsing”); then you need to compute the output by filling in meta-variables in the match arm body (“transcribing”). r-a’s mbe/expander/matcher.rs, which implements the parsing step, has a top-level comment...
Rust Walkthroughs 2026-05-06 ~10 min read
github.com
...DefId) -> ParamEnv<'tcx> { if tcx.describe_def(def_id) match Some(Def::Existential(_)) && tcx.hir.as_local_node_id(def_id) match Some(node_id) && tcx.hir.get(node_id) match hir::map::NodeItem(item) && item.node match hir::ItemExistential(ref exist_ty) && exist_ty.impl_trait_fn match Some...
RFC 2497 RFC 2018-07-13 ~57 min read
owengage.com
...We can match on this to call the appropriate visitor methods. Here is a cut down version of deserialize_any: fn deserialize_any<V>(mut self, v: V) -> Result<V::Value> where V: de::Visitor<'de>, { match self.tag { Tag::Byte => v.visit_i8(self.de.input.consume_byte()? as...
Rust Walkthroughs 2022-08-10 ~7 min read
paulkoerbitz.de
...When we apply `match` to a dereferenced borrowed pointer, we cannot move because we don't have ownership. Changing the `match_and_print` function to take a value would work again. ~~~{.rust} fn match_and_print(e: MyEnum) { match e { MyEnum::X(x) => println!("{}", x), MyEnum::Y(y) => println!("{}", *y...
Announcements, etc 2014-01-18 ~13 min read
micahkepe.com
...Dots (.) between field names denote concatenation-- "match this field, then that field":$ cat sample.json | jg 'roommates[0].name' roommates.[0].name: "Alice"BashWildcards match any single key (*) or any array index ([*]):$ cat sample.json | jg 'favorite_drinks[*]' favorite_drinks.[0]: "coffee" favorite_drinks.[1]: "Dr. Pepper" favorite_drinks.[2...
Project/Tooling Updates 2026-04-01 ~13 min read
ck.kennt-wayne.de
...let mut result = match results.get_mut(i) { Some(v) => v, None => panic!("error! no value!") }; The return value of get_mut() is just an enum, but in Rust enums may contain additionally a value. This leads to constructs like above. The match keyword introduces a pattern matching construct and...
Blog Posts 2015-01-05 ~5 min read
blog.datalust.co
...let index_quote = { let match_quote = _mm256_cmpeq_epi8(block, _mm256_set1_epi8(b'"' as i8)); let index_quote = _mm256_movemask_epi8(match_quote); let match_escape = _mm256_cmpeq_epi8(block, _mm256_set1_epi8(b'\\' as i8)); let index_escape = _mm256_movemask_epi8(match_escape); index_quote | index_escape }; The...
Learn More Rust 2020-09-09 ~20 min read
blog.sylver.dev
...Token) -> bool { self.tokens.get(self.pos) == Some(&expected) } fn expect_identifier(&mut self) -> anyhow::Result<&str> { self.expect_matching(|t| matches!(t, Token::Identifier(_))) .map(|t| t.as_identifier().unwrap()) } fn expect_eq(&mut self, expected: Token) -> anyhow::Result<&Token> { self.expect_matching(|t| *t == expected) } fn expect_matching...
Rust Walkthroughs 2024-11-20 ~9 min read
doc.rust-lang.org
...let mut s = String::new(); match process.stdout.unwrap().read_to_string(&mut s) { Err(why) => panic!("couldn't read wc stdout: {}", why), Ok(_) => print!("wc responded with:\n{}", s), } }
Rust by Example Book 2024-01-01 ~1 min read
blog.frankel.ch
...The language models it as an enum with generics on each value: #[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] pub enum Result<T, E> { Ok(T), Err(E), } Because Rust manages completeness of matches, matching on Result enforces that you handle both branches: match fn_that_returns_a_result...
Observations/Thoughts 2024-02-14 ~4 min read
rust-lang.github.io
...rust-lang/rust#44495 Summary Currently when using an if let statement and an irrefutable pattern (read always match) is used the compiler complains with an E0162: irrefutable if-let pattern. The current state breaks macros who want to accept patterns generically and this RFC proposes changing this error to...
Updates from Rust Core 2018-07-03 ~1 min read
www.ntietz.com
...Vec<String>) -> Result<Matches, ParseError> { let mut args_iter = args.into_iter(); let exec_name = match args_iter.next() { Some(s) => s, None => return Err(ParseError::MissingProgramName), }; Next we setup our storage and populate the defaults with our helper function. // pub fn parse(&self, args: Vec<String>) -> Result<Matches, ParseError...
Rust Walkthroughs 2024-11-06 ~11 min read
ntietz.com
...Vec<String>) -> Result<Matches, ParseError> { let mut args_iter = args.into_iter(); let exec_name = match args_iter.next() { Some(s) => s, None => return Err(ParseError::MissingProgramName), }; Next we setup our storage and populate the defaults with our helper function. // pub fn parse(&self, args: Vec<String>) -> Result<Matches, ParseError...
Rust Walkthroughs 2024-11-13 ~11 min read
rodrigodd.github.io
...loop { use Instruction::*; match self.instructions[self.program_counter] { // ... Clear => self.memory[self.pointer] = 0, } // ... } And every time we parse a ] we check if the previous instructions match the “clear cell” operation, and replace it by the new instruction. b']' => { let curr_address = instructions.len(); match bracket_stack.pop() { Some...
Observations/Thoughts 2022-10-26 ~20 min read
llogiq.github.io
...if the closing delimiter is on the same line, ignore both if there is only one opening delimiter on that line, the set only contains the horizontal position of the first non-whitespace character of that line otherwise we need to match the position of the first non-whitespace character...
News & Blog Posts 2016-08-30 ~2 min read
siciarz.net
...Time for our first request! extern crate hyper; use hyper::Url; use hyper::client::Request; fn main() { let url = match Url::parse("http://httpbin.org/status/200") { Ok(url) => url, Err(_) => panic!("Uh oh."), }; println!("> get: {}", url); let fresh_request = match Request::get(url) { Ok(request) => request, Err(_) => panic!("Whoops...
Blog Posts 2014-12-08 ~4 min read
blog.sheerluck.dev
...Vec<(usize, String)> = Vec::new(); let mut line_number = 1; for line in contents.lines() { let is_match = regex.is_match(line); let should_include = if invert { !is_match } else { is_match }; if should_include { results.push((line_number, line.to_string())); } line_number += 1; } results } We are borrowing contents...
Rust Walkthroughs 2026-04-15 ~15 min read
arzg.github.io
...u8) { let checkpoint = p.checkpoint(); match p.peek() { Some(SyntaxKind::Number) | Some(SyntaxKind::Ident) => p.bump(), Some(SyntaxKind::Minus) => { let op = PrefixOp::Neg; let ((), right_binding_power) = op.binding_power(); } _ => {} } loop { let op = match p.peek() { Some(SyntaxKind::Plus) => InfixOp::Add, Some(SyntaxKind::Minus) => InfixOp::Sub, Some(SyntaxKind::Star) => InfixOp...
Rust Walkthroughs 2020-11-18 ~6 min read
"all the ergonomic improvements in rust 2018 are really messing up my book that consists entirely of running face-first into compiler errors so i can e..."
— Alexis Beingessner, author of “Learning Rust With Entirely Too Many Linked Lists”

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.