Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
ettolrach.com
...In the first, we make use of pattern matching. Note how there are no cases to cover, that means there are no patterns we need to match. In the second, we make use of the function which is commonly known as absurd, whose type is 1. A quick refresher on...
Observations/Thoughts 2026-09-09 ~13 min read
cglab.ca
...Ord, V> Map<K, V> for BTreeMap<K, V> { fn find(&self, key: &K) -> Option<&V> { let mut cur_node = &self.root; loop { match cur_node.search(key) { Found(i) => return cur_node.val(i), GoDown(i) => match cur_node.edge(i) { None => return None, Some(next_node) => { cur_node...
Observations/Thoughts 2021-02-03 ~35 min read
ibraheem.ca
...Like a match statement, but for I/O operations. loop { // If only... match { ctrl_c() => { break; }, Ok((connection, _)) = listener.accept() => { std::thread::spawn(|| ...); } } } And what about timing out long running requests after thirty seconds? We could set a flag that tells threads to stop, but how often would they check...
Observations/Thoughts 2023-08-16 ~88 min read
rust-lang.github.io
...let a: [uint; 2] = [0u; 2]; Match patterns In match patterns, .. is always interpreted as a wildcard for constructor arguments (or for slice patterns under the advanced_slice_patterns feature gate). This RFC does not change that. In a match pattern, .. will always be interpreted as a wildcard, and never...
RFC 520 RFC 2014-12-13 ~5 min read
FOSDEM video.fosdem.org
...These guarantees are not formally specified, which makes it harder to reason about the safety of the wrapped unsafe logic; this issue is compounded by the fact that undefined behaviour can seep into safe rust from unsafe code that doesn't match rust's expected semantics. I'll discuss how...
Talk Andrea Lattuada 2019-02-02
quickwit.io
...a RegexPhraseQuery "b.* b.* wolf" matches "big bad wolf". Slop is supported as well: "bi.* wolf"~2 matches "big bad wolf". #2516This feature comes with some new Postings implementations to handle the complexity of potentially 100000 terms. They may be useful for other use cases:SimpleUnion A union docset for...
Project/Tooling Updates 2025-06-25 ~3 min read
pietro.menna.net.br
...PeerMessage) -> Result<(), Error> { match message { PeerMessage::CancelRequest(piece_index, block_index) => { match self.requests_in_progress.iter().position(|r| r.matches(piece_index, block_index)) { Some(i) => { let r = self.requests_in_progress.remove(i); self.send_message(Message::Cancel(r.piece_index, r.offset, r.block_length)) }, None => Ok...
From the Blogosphere 2015-06-22 ~7 min read
aturon.github.io
...DomString) -> AttrValue { match name { &atom!("id") => AttrValue::from_atomic(value), &atom!("class") => AttrValue::from_serialized_tokenlist(value), _ => default::parse_plain_attribute(self, name, value), } } } impl ParsePlainAttribute for HtmlAnchorElement { fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { match name { &atom!("rel") => AttrValue::from_serialized_tokenlist(value), _ => default::parse_plain...
News & Blog Posts 2015-09-21 ~24 min read
crates.io
...This allows us to write custom preconditions for matching code. Let's make this more clear with a concrete example. Here is the declaration of an external extractor to match on the high-level instruction that defined a given operand Value , along with a new rule to sink loads into...
Crate v0.138.0 2026-11-20
doc.rust-lang.org
pub const fn as_mut(&mut self) -> Option<&mut T>
Option::as_mut — Converts from &mut Option<T> to Option<&mut T>. Examples let mut x = Some(2); match x.as_mut() { Some(v) => *v = 42, None => {}, } assert_eq!(x, Some(42));
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn connect<P>(path: P) -> io::Result<UnixStream>
UnixStream::connect — Connects to the socket named by path. Examples use std::os::unix::net::UnixStream; let socket = match UnixStream::connect("/tmp/sock") { Ok(sock) => sock, Err(e) => { println!("Couldn't connect: {e:?}"); return } };
associated_function std Stable since 1.10.0 Version 1.100.0-nightly
www.snoyman.com
...f64, } #[derive(Clone, Copy)] enum State { Arizona, Nevada, Utah, } impl State { fn tax_rate(self) -> f64 { match self { State::Arizona => 0.05, State::Nevada => 0.08, State::Utah => 0.09, } } } #[derive(Clone, Copy)] enum Item { Apples, Eggs, } impl Item { fn price(self) -> f64 { match self { Item::Apples => 0.5, Item...
Rust Walkthroughs 2024-08-28 ~10 min read
www.fpcomplete.com
...So let's rewrite this without any early return, and instead use some pattern matching: fn age() -> Option<i32> { match (birth_year(), current_year()) { (Some(birth_year), Some(current_year)) => Some(current_year - birth_year), _ => None, } } This certainly works, but it's verbose. It also doesn't generalize to other...
Observations/Thoughts 2020-12-09 ~22 min read
dystroy.org
...Result<T, E>) -> T { match res { Ok(v) => v, Err(e) => { log::error!("Fatal error: {}", e); Timer::after_millis(100).await; panic!("Fatal error: {}", e); } } } #[embassy_executor::main] async fn main(spawner: Spawner) { let p = embassy_rp::init(Default::default()); // Logger USB — must be before everything else let usb_driver...
Rust Walkthroughs 2026-06-17 ~50 min read
rust-lang.github.io
...However, if you're using Clippy, this will cause the match_same_arms lint to trip! You can silence the lint in this spot, and provide an explanation that indicates you are doing so deliberately, by placing this attribute above the match line: #[allow(match_same_arms, reason = "The arms...
RFC 2383 RFC 2018-04-02 ~9 min read
matthewkmayer.github.io
...fn make_org_url(matches: &clap::ArgMatches) -> String { let org = matches .value_of("ORG") .expect("Please specify a github org"); if !org_is_just_org(&org) { match suggest_org_arg(&org) { Ok(suggestion) => panic!("Try this for the org value: {}", suggestion), Err(_) => panic!("Please make org just the organization name...
News & Blog Posts 2017-10-24 ~6 min read
www.worthe-it.co.za
...It follows that the lifetime of variables used inside the new thread must match those of the new thread, not the function that it was spawned from.use std::thread; let outside_value = String::from("Hello world"); let child_thread = thread::spawn(move || { // this new thread may outlive the context...
News & Blog Posts 2017-07-18 ~10 min read
blog.scottlogic.com
...It first casts times to a signed integer so that it can support negative values and uses a match to work out a transformation to apply based on the current direction. The match control-flow operator is an extremely powerful feature of Rust, similar to Scala’s match or a...
Learn Simple Rust 2020-10-14 ~36 min read
docs.rs
...cannot move out of borrowed content *self = match *self { // ^^^^^ cannot move out of borrowed content States::A(a) => States::B(a), States::B(a) => States::A(a), }; } } Depending on context this can be quite tricky to work around. With this crate, however: enum States { A(String), B(String), } impl States...
Crate v0.1.8 2025-05-20
jtjlehi.github.io Archived: primary link replaced with an archive on 2026-09-12T14:44:56.786Z (UTC; replacement date, not snapshot date)
...let (removes, inserts): (Vec<_>, Vec<_>) = updates .into_iter() // we have to make sure that removes happen at the correct offset .scan(0, |num_inserts, update| { Some(match update { Update::Remove(idx) => Update::Remove(idx + *num_inserts), insert @ Update::Insert(_, _) => { *num_inserts += 1; insert } }) }) .partition(|updates| matches!(updates, Update::Remove(_))) To...
Rust Walkthroughs 2025-03-26 ~14 min read
"I sure need to work on my quotes."

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.