Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
rodarmor.com
...for c in text.chars() { match state { … State::Backslash => { match c { 'n' => cooked.push('\n'), … } … } … } } So just asks rustc to insert the result of evaluating the Rust '\n' character escape. Let's take a look at how rustc handles '\n'. rustc's escape code handling is in the lexer, in...
Observations/Thoughts 2024-10-02 ~2 min read
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
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
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
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
rust-lang.github.io
...Result<!, E>) -> Self { match x { Err(e) => Err(From::from(e)), } } } But Option doesn't need to do anything exciting, so just has a simple implementation, taking advantage of the default parameter: impl<T> FromResidual for Option<T> { fn from_residual(x: Self::Residual) -> Self { match x { None => None, } } } In...
RFC 3058 RFC 2020-12-12 ~39 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
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
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
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.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
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
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
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
rust-lang.github.io
Summary Make the count parameter of SliceExt::splitn, StrExt::splitn and corresponding reverse variants mean the maximum number of items returned, instead of the maximum number of times to match the separator. Motivation The majority of other languages (see examples below) treat the count parameter as the maximum number of...
RFC 979 RFC 2015-03-15 ~2 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
rust-lang.github.io
...Crates scope The patterns will be evaluated during each API call, and if no match is found the request will be denied. Because it's evaluated every time, a crates scope will allow interacting with matching crates published after token creation. The check for the crates scope is separate from...
RFC 2947 RFC 2022-11-08 ~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
"\[..\] if a breaking change is going to happen, it’s much better to make lock automatically panic than to make panics silently unlock."

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.