Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
noiseonthenet.space
...T ) { match self.root{ None => { self.root = Node::new(value).into(); } Some(ref mut node) => { Tree::<T>::insert_recursive(node, value); } } } fn insert_recursive(node : & mut Node<T>, value : T){ if value > node.value{ match node.right{ None => { node.right = Node::new(value).into(); } Some(ref mut n) => { Tree::<T...
Observations/Thoughts 2024-04-17 ~7 min read
dev.to
...Stripping unwanted trailing characters went from a slow regex match inside a loop: // The old, slow regex way pub(crate) fn trim_unwanted_end_chars<'a>(&self, phone_number: &'a str) -> &'a str { // ... loop with regex.full_match() ... } Enter fullscreen mode Exit fullscreen mode To a single, native Rust iterator...
Project/Tooling Updates 2026-03-11 ~7 min read
arzg.github.io
...u8) { let mut lhs = match p.peek() { // snip }; loop { let op = match p.peek() { Some(SyntaxKind::Plus) => InfixOp::Add, Some(SyntaxKind::Minus) => InfixOp::Sub, Some(SyntaxKind::Star) => InfixOp::Mul, Some(SyntaxKind::Slash) => InfixOp::Div, _ => return, // we’ll handle errors later. }; let (left_binding_power, right_binding_power) = op.binding_power...
Rust Walkthroughs 2020-12-16 ~16 min read
svartalf.info
...io_object_t) -> kern_return_t; } unsafe { let match_dict = IOServiceMatching( b"IOPMPowerSource\0".as_ptr() as *const c_char ); let mut iterator: io_iterator_t = mem::uninitialized(); // TODO: Handle the possible error let _result = IOServiceGetMatchingServices( master_port, match_dict, &mut iterator, ); } IOServiceMatching documentation says that the returned match_dict...
News & Blog Posts 2019-06-04 ~7 min read
doma.dev
...Equivalently, one can't solve the matching parentheses problem with a regular expression. The simplest stack machine is needed for that. Stack automaton can be in several states at once. A state with no transitions "fizzles" on any input. (@\* matches character '(' with any stack state. ε@ε matches instantaneously as...
Rust Walkthroughs 2021-03-31 ~8 min read
github.com
...To reduce risk of tools in the ecosystem unintentionally matching pre-releases (despite them still needing an opt-in), it might be reasonable for the `semver` package to offer this new matching behavior under a different name (e.g. `VersionReq::matches_prerelease` in contrast to the existing `VersionReq::matches`) (also...
RFC 3493 RFC 2023-09-20 ~9 min read
rust.code-maven.com
...u32 = match args[1].parse() { Ok(value) => value, Err(err) => { eprintln!("Invalid parameter: '{}'. It must be an integer", err); eprintln!("Usage: {} INTEGER", &args[0]); std::process::exit(1); } }; number } Here we have a match that is expected to return a 32-bit unsigned integer, a u32. However, if the user...
Miscellaneous 2023-12-06 ~3 min read
boats.gitlab.io
...Match ergonomics Match ergonomics have been stable for a while, but I continue to find them paying dividends. I’m sure there are times where I’ve used it without even noticing it, but there were many cases where I did notice. My experience usually went like this: I write...
News & Blog Posts 2018-07-31 ~6 min read
rust-analyzer.github.io
...ignore macro imports from extern crate self. #8863 don’t add extra whitespace around fields. #8880 fix module renaming. #8875 avoid false positive "Missing match arm" when an or-pattern has mismatched types. #8884 fix "Add explicit type" producing invalid code on @ patterns. #8893 update outdated auto-import documentation. #8902...
Project/Tooling Updates 2021-05-26 ~1 min read
doc.rust-lang.org
...3 }; match foo { Foo { x: (1, b), y } => println!("First of x is 1, b = {}, y = {} ", b, y), // you can destructure structs and rename the variables, // the order is not important Foo { y: 2, x: i } => println!("y is 2, i = {:?}", i), // and you can also ignore some variables: Foo...
Rust by Example Book 2024-01-01 ~1 min read
kerkour.com
...Pattern matching in Rust can be used to match against many other expressions: match x { 42 => println!("Good!"), _ => println!("Bad!"), } let boolean = true; // Match is an expression too let binary = match boolean { false => 0, true => 1, }; let x = Some(42u64); match x { Some(1) => println!("1"), Some(42) => println!("42...
Rust Walkthroughs 2022-03-09 ~9 min read
smallcultfollowing.com
...it starts as we enter the match (match &message) and continues into the match arm. On the else branch of the match, the borrow is still in use (in the form of the data variable), but in the if branch, it is not (and hence we can call tx.send...
News & Blog Posts 2018-11-06 ~5 min read
www.diegofreijo.com
...pub fn scan_token(&mut self) -> TokenResult<'a> { self.skip_whitespaces(); self.start = self.current; match self.advance() { Some(c) => match c { _ if Scanner::is_alpha(c) => self.identifier(), _ if Scanner::is_digit(c) => self.number(), // Single-char tokens '(' => self.make_token(TokenType::LeftParen), ')' => self.make_token(TokenType::RightParen), // (...) '<' => self...
Rust Walkthroughs 2022-02-09 ~13 min read
blog.burntsushi.net
...Match In this case, Split means “jump to two different instructions simultaneously.” In particular, if either branch executes the Match instruction, then the entire regex will match. If both Char instructions fail, then it’s impossible to reach the Match instruction. Clarifying the divide: native regexes vs. dynamic regexes The...
Community Updates 2014-05-05 ~18 min read
doc.rust-lang.org
...let mut into_iter = vec2.into_iter(); // `iter()` yields `&i32`, and `find` passes `&Item` to the predicate. // Since `Item = &i32`, the closure argument has type `&&i32`, // which we pattern-match to dereference down to `i32`. println!("Find 2 in vec1: {:?}", iter.find(|&&x| x == 2)); // `into_iter()` yields `i32`, and...
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
while let Similar to if let, while let can make awkward match sequences more tolerable. Consider the following sequence that increments i: // Make `optional` of type `Option<i32>` let mut optional = Some(0); // Repeatedly try this test. loop { match optional { // If `optional` destructures, evaluate the block. Some(i) => { if i...
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
...use std::fs::File; use std::io::prelude::*; use std::path::Path; fn main() { // Create a path to the desired file let path = Path::new("hello.txt"); let display = path.display(); // Open the path in read-only mode, returns `io::Result<File>` let mut file = match File::open(&path) { Err...
Rust by Example Book 2024-01-01 ~1 min read
lwn.net
...Matches involving tuples, for example, must try matching a single element at a time, which is something that the GCC internal representation wasn't designed to do. Arm guards (essentially an extra if controlling whether a specific match occurs) also complicate things, since the variables set by the match must...
Observations/Thoughts 2022-10-26 ~8 min read
santiagopastorino.com
...usize) -> &mut String { match map.get_mut(&key) { Some(value) => value, None => { map.insert(key, "".to_string()); map.get_mut(&key).unwrap() } } } fn main() { let map = &mut HashMap::new(); map.insert(22, format!("Hello, world")); map.insert(44, format!("Goodbye, world")); assert_eq!(&*get_default(map, 22), "Hello, world"); assert...
News & Blog Posts 2018-01-09 ~5 min read
doc.rust-lang.org
...fn main() { // Try changing the values in the array, or make it a slice! let array = [1, -2, 6]; match array { // Binds the second and the third elements to the respective variables [0, second, third] => println!("array[0] = 0, array[1] = {}, array[2] = {}", second, third), // Single values can be ignored...
Rust by Example Book 2024-01-01 ~1 min read
"`Rc<RefCell>` is like duct tape. It's very versatile, and can fix a multitude of problems in a pinch. For some problems, it's even the best thing to ..."

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.