rustc-dev-guide.rust-lang.org
...Note that exactly one of the matchers from the various rules should match the invocation; if there is more than one match, the parse is ambiguous, while if there are no matches at all, there is a syntax error.
Assuming exactly one rule matches, macro expansion will then transcribe the...
Guide to Rustc Development
Book
2024-01-01
~16 min read
worldwithouteng.com
...Handling these error variants is straightforward on the calling side thanks to Rust’s pattern matching. Using the match statement, you can easily run different code for different error variants. Further, the compiler ensures that your match statement is exhaustive. If you ever add a new error variant but forget...
Rust Walkthroughs
2023-11-01
~8 min read
docs.rs
...will be matched from the global root (prefix matches). All other paths will be matched as suffix matches. (=<boolean>) : Boolean values may be specified after a parameter, but if not, the value is assumed to be true by virtue of having listed the parameter. Usage with buf When used with...
Crate
v0.5.0
2025-11-30
matthewkmayer.github.io
...let credentials = DefaultCredentialsProvider::new()
.expect("Couldn't create AWS credentials provider.");
Knowing when to use expect instead of matching against Result or Option is worth understanding. In our sample code, panicking if we can’t get AWS credentials is probably what we want to do. But what about calls to...
News & Blog Posts
2017-06-06
~7 min read
arXiv
arxiv.org
...An empirical evaluation on 16 micro-benchmarks confirms that compile-time specialization matches or outperforms runtime TypeId-based dispatch, and demonstrates expressiveness gains on patterns -- such as lifetime-based dispatch, higher-ranked types, compound predicates, and wildcard matching -- that runtime dispatch structurally cannot express.
Programming Languages
Federico Bruzzone, Walter Cazzola
2026-02-13
arXiv:2602.12973
kerkour.com
...They match routes (URLs). For example, the Login page matches the /login route. The Home page matches the / route.
And finally, Services are auxiliary utilities to wrap low-level features or external services such as an HTTP client, Storage...
The goal of our application is simple: It's a portal...
Rust Walkthroughs
2022-06-15
~5 min read
levpaul.com
...For now I’ve just set this command as a build target for when I need it but I’m sure it will eventually annoy me enough to find a better answer.match match guess.cmp(&secret_number) {
Ordering::Less => println!("Too small!"),
Ordering::Greater => println!("Too big!"),
Ordering::Equal...
Learn Rust
2020-10-28
~7 min read
crates.io
...type JsonArray = Vec<Box<Value>>; type JsonObject = HashMap<String,Box<Value>>; #[derive(Debug, Clone, PartialEq)] pub enum Value { Str(String), Num(f64), Bool(bool), Arr(JsonArray), Obj(JsonObject), Null } fn scan_json(scan: &mut Scanner) -> Result<Value,ScanError> { use Value::*; match scan.get() { Token::Str(s) => Ok(Str(s)), Token...
Crate
v0.2.0
2026-07-25
49:19
Rustacean Station
rustacean-station.org
Episode: What's New in Rust 1.40
...It means that no one can match on your type without including sort of the underscore pattern.
Right?
They need, when they do the match,
they always need to write the code under the assumption that more things might be added.
And there are a lot of places where this...
Podcast
2020-01-13
49:19
codeandbitters.com
...It allows us to apply a closure to convert the matched string into
something else: in the json_bool case, one of the JsonBool variants. You
will probably smell something funny about that code, though: we already matched
the "true" and "false" strings once in the parser generated by the...
News & Blog Posts
2020-07-14
~33 min read
docs.rs
...It may need to match request headers specified in Vary . Even a matching fresh response may still not be usable if the new request restricted cacheability, etc. The key method is before_request(new_request) , which checks whether the new_request is compatible with the original request and whether all...
Crate
v3.0.0
2026-02-04
willcrichton.net
...These mechanisms can ensure that two variadic argument lists share important properties, like the number of format string holes matches the number of printf arguments.
Part of an ongoing series about type-level programming in Rust. Consider reading part one first! All code in this note can be found in...
News & Blog Posts
2020-06-23
~6 min read
willcrichton.net
...These mechanisms can ensure that two variadic argument lists share important properties, like the number of format string holes matches the number of printf arguments.
Part of an ongoing series about type-level programming in Rust. Consider reading part one first! All code in this note can be found in...
Learn More Rust
2020-08-11
~6 min read
rust.code-maven.com
...Vec<(&str, &str)>) -> surrealdb::Result<()> {
for (name, phone) in data {
let response = db
.query("CREATE entry SET name=$name, phone=$phone")
.bind(("name", name))
.bind(("phone", phone))
.await?;
match response.check() {
Ok(_) => {}
Err(err) => {
eprintln!("Could not add entry: '{}'", err);
return Err(err);
}
};
}
Ok(())
}
SELECT to fetch data
This query...
Miscellaneous
2024-01-17
~6 min read
doc.rust-lang.org
fn position<P>(&mut self, predicate: P) -> Option<usize>
...Overflow Behavior
The method does no guarding against overflows, so if there are more than usize::MAX non-matching elements, it either produces the wrong result or panics. If overflow checks are enabled, a panic is guaranteed.
Panics
This function might panic if the iterator has more than usize::MAX...
method
core
Stable since 1.0.0
Version 1.100.0-nightly
www.chriskrycho.com
...Rust’s match and Swift’s switch and case fill the same role of pattern matching. I’m curious to see how they differ. Does Swift do matching on arbitrary expressions?
Also, I see where the syntax choices came from in both, and while I slightly prefer Rust’s, I...
News & Blog Posts
2015-10-26
~3 min read
agourlay.github.io
...usize = match args_iter.next() {
- None => num_cpus::get_physical(),
- Some(count) => count.parse().unwrap(),
- };
+ let batch_size: usize = args_iter.next().unwrap().parse().unwrap();
+
+ let workers: usize = num_cpus::get_physical();
- match password_finder(&zip_path, dictionary_path, workers) {
+ match password_finder(&zip_path, dictionary_path, workers, batch_size...
Observations/Thoughts
2022-10-05
~26 min read
rust-analyzer.github.io
...include! and other eager macros work in expression position.
#8970 duplicate dependencies that have multiple DepKinds.
#8975 use todo!() as placeholder body for generated match arms.
#8983 fix type mismatch caused by macros.
#8986 add "Go to type definition" for struct fields within struct.
#8989 try to fix type inference...
Project/Tooling Updates
2021-06-02
~1 min read
joelmccracken.github.io
...open(filename));
try!(file.write_all(bytes));
Ok(())
}
fn log_time(filename: &'static str) -> io::Result<()> {
let entry = formatted_time_entry();
let bytes = entry.as_bytes();
try!(record_entry_in_log(filename, &bytes));
Ok(())
}
fn main2() {
match log_time("log.txt") {
Ok(..) => println!("File created!"),
Err(e) => println!("Error: {}", e...
From the Blogosphere
2015-07-06
~10 min read
pliniker.github.io
...When computed gotos and optimized tail calls are unavailable, the fallback standard is to use
switch/match statements. It must be noted that a switch/match compiles to a single computed goto,
but it cannot be used to jump to arbitrary points in a function as with the full Computed...
Observations/Thoughts
2021-09-08
~11 min read