Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
doc.rust-lang.org
?
? Chaining results using match can get pretty untidy; luckily, the ? operator can be used to make things pretty again. ? is used at the end of an expression returning a Result, and is equivalent to a match expression, where the Err(err) branch expands to an early return Err(From::from...
Rust by Example Book 2024-01-01 ~1 min read
github.com
...ReverseSearcher<&'a Self>; pub fn trim_matches<'a, P>(&'a self, pat: P) -> &'a Self where P: Pattern<&'a Self>, P::Searcher: DoubleEndedSearcher<&'a Self>; pub fn trim_left_matches<'a, P>(&'a self, pat: P) -> &'a Self where P: Pattern<&'a Self>; pub fn trim_right_matches<'a, P...
RFC 2295 RFC 2018-01-16 ~14 min read
doc.rust-lang.org
...The exception is that the outer delimiters for the matcher will match any pair of delimiters. Thus, for instance, the matcher (()) will match {()} but not {{}}. The character $ cannot be matched or transcribed literally. Forwarding a matched fragment When forwarding a matched fragment to another macro-by-example, matchers in the...
The Rust Reference Book 2024-01-01 ~18 min read
huonw.github.io
Rust’s match statement can do a lot of things, even C-style fallthough to the next branch, despite having no real support for it. It turns out to be a “shallow” feature, where the C to Rust translation is easily done, without needing to understand the code itself. The...
Observations/Thoughts 2025-03-05 ~8 min read
blog.meilisearch.com
...IS EMPTY matches existing attributes with empty value while IS NULL  matches fields with a null value. Here’s an example considering the following documents: [ { "id": 0, "color": [] }, { "id": 1, "color": null }, { "id": 2, } ] The new filter operators work like this: color IS EMPTY: matches document 0 color IS NULL...
Project/Tooling Updates 2023-06-07 ~4 min read
stopa.io
...fn env_get(k: &str, env: &RispEnv) -> Option<RispExp> { match env.data.get(k) { Some(exp) => Some(exp.clone()), None => { match &env.outer { Some(outer_env) => env_get(k, &outer_env), None => None } } } } fn eval(exp: &RispExp, env: &mut RispEnv) -> Result<RispExp, RispErr> { match exp { RispExp::Symbol(k) => env_get...
Rust Walkthroughs 2020-12-02 ~15 min read
dev.to
...fn read_username_from_file() -> Result<String, io::Error> { let f = File::open("username.txt"); let mut f = match f { Ok(file) => file, Err(e) => return Err(e), }; let mut s = String::new(); match f.read_to_string(&mut s) { Ok(_) => Ok(s), Err(e) => Err(e), } } Enter fullscreen mode...
Learn Simple Rust 2020-10-21 ~4 min read
leshow.github.io
...Write, { match var { Var::One => serde_json::to_writer(&mut writer, &Foo), Var::Two => serde_json::to_writer(&mut writer, &Bar), } } fn write_pretty<W>(var: Var, mut writer: W) -> serde_json::Result<()> where W: Write, { match var { Var::One => serde_json::to_writer_pretty(&mut writer, &Foo), Var::Two...
News & Blog Posts 2020-05-05 ~5 min read
flinect.com
...One macro I really like is matches!. It's basically a single-arm match expression, but you can readably use it in if statements. So, this: match data_type.id { ParsedDataTypeId::Standard(ref data_type_id) if data_type_id == "data-trait-name" => { // ... } _ => {} } Can be written as: if matches!(data...
Rust Walkthroughs 2023-11-29 ~6 min read
gsquire.github.io
...This is a powerful construct in that it can match multiple patterns that you provide in a single scan. Using this idea, I thought it would be fun to write a router with a RegexSet matching requests under the hood. The result of this is reroute. This crate provides a...
News & Blog Posts 2016-06-20 ~2 min read
blog.logrocket.com
...Understanding match in Rust Feel free to skip to the next section if you already understand pattern matching. Before exploring how that’s even possible, let’s understand Rust’s idea of pattern matching. Here’s a scenario: A hungry customer asks for a meal from our Korean street food...
Rust Walkthroughs 2021-07-28 ~11 min read
rust-lang.github.io
...i32 = match some_bool { true => 23, false => panic!("aaah!"), // an expression of type `!`, gets cast to `i32` } match break { () => 23, // matching with a `()` forces the match argument to be cast to type `()` } These casts can be implemented by having the compiler assign a fresh, diverging type variable to any expression...
Updates from Rust Core 2018-03-20 ~12 min read
github.com
...i32 = match some_bool { true => 23, false => panic!("aaah!"), // an expression of type `!`, gets cast to `i32` } match break { () => 23, // matching with a `()` forces the match argument to be cast to type `()` } ``` These casts can be implemented by having the compiler assign a fresh, diverging type variable to any expression...
RFC 1216 RFC 2015-07-19 ~13 min read
apanatshka.github.io
...Debug; fn start_state() -> Self::State; fn next_state(&self, state: &Self::State, input: &Input) -> Self::State; fn get_match(&self, state: &Self::State, text_offset: usize) -> Option<Match<Payload>>; fn find<'i, 'a>(&'a self, s: &'i [Input]) -> Matches<'i, 'a, Input, Payload, Self> where Self: Sized { Matches { aut...
News & Blog Posts 2016-10-04 ~11 min read
github.com
...Some libraries (like Python's `re` and RE2/C++) distinguish between matching an expression against an entire string and matching an expression against part of the string. My implementation favors simplicity: matching the entirety of a string requires using the `^` and/or `$` anchors. In all cases, an implicit `.*?` is added...
RFC 42 RFC 2014-04-12 ~9 min read
blog.ezyang.com
...When match is involved, you can usually arrange for the misbehaving borrow to be performed outside of the match statement, in a new, non-overlapping lexical scope. This is easy when the relevant branch does not rely on any variables from the pattern-match by using short-circuiting control operators...
Announcements, etc 2013-12-22 ~8 min read
doc.rust-lang.org
...The second arm of the outer match stays the same, so the program panics on any error besides the missing file error. Alternatives to Using match with Result<T, E> That’s a lot of match! The match expression is very useful but also very much a primitive. In Chapter...
The Rust Programming Language Book 2024-02-01 ~18 min read
doc.rust-lang.org
...io::Result<()> { match OpenOptions::new().create(true).write(true).open(path) { Ok(_) => Ok(()), Err(e) => Err(e), } } fn main() { println!("`mkdir a`"); // Create a directory, returns `io::Result<()>` match fs::create_dir("a") { Err(why) => println!("! {:?}", why.kind()), Ok(_) => {}, } println!("`echo hello > a/b.txt`"); // The previous match can be...
Rust by Example Book 2024-01-01 ~2 min read
gruebelinchen.wordpress.com
...It uses a placeholder, which we call ActualT, to specify the type of the value being matched. Rust provides two ways to express this. One can define a generic trait with a type parameter: 123trait Matcher<ActualT> {    fn matches(&self, actual: &ActualT) -> bool;} Or one can add an associated type...
Observations/Thoughts 2023-06-07 ~7 min read
andygrove.io
...However, we still have to pattern match for dynamic behavior at runtime. We can’t pattern match on the BufferArrayData itself but instead have to pattern match on the separate type metadata. fn add(a: &ArrayData, a_type: DataType, b: &ArrayData, b_type: DataType) -> Rc<ArrayData> { match (a_type, b...
News & Blog Posts 2018-05-08 ~5 min read
"In Rust it’s the compiler that complains, with C++ it’s the colleagues"

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.