Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
ohadravid.github.io
...poly_match_rs.poly_match_rs.find_close_polygons() takes no arguments (3 given) v1 - A naive Rust translationWe’ll start with matching the expected API.PyO3 is pretty smart about Python to Rust conversions, so that’s going to be pretty easy:#[pyfunction] fn find_close_polygons(polygons: Vec...
Rust Walkthroughs 2023-03-29 ~17 min read
doc.rust-lang.org
pub struct RSplit<'a, T, P>
RSplit — An iterator over subslices separated by elements that match a predicate function, starting from the end of the slice. This struct is created by the rsplit method on slices. Example let slice = [11, 22, 33, 0, 44, 55]; let mut iter = slice.rsplit(|num| *num == 0); assert_eq!(iter...
struct core Stable since 1.27.0 Version 1.100.0-nightly
doc.rust-lang.org
pub struct SplitN<'a, T, P>
SplitN — An iterator over subslices separated by elements that match a predicate function, limited to a given number of splits. This struct is created by the splitn method on slices. Example let slice = [10, 40, 30, 20, 60, 50]; let mut iter = slice.splitn(2, |num| *num % 3 == 0); assert...
struct core Stable since 1.0.0 Version 1.100.0-nightly
github.com
...use file_diff::{diff_files}; use std::fs::{File}; let mut file1 = match File::open("./src/lib.rs") { Ok(f) => f, Err(e) => panic!("{}", e), }; let mut file2 = match File::open("./src/lib.rs") { Ok(f) => f, Err(e) => panic!("{}", e), }; diff_files(&mut file1, &mut file2); The diff() function...
Crate v1.0.0 2016-04-10
andidog.de
...Here’s how I could match State::Failed(String): $enum_name::$enum_variant(..) => $int_value Note that this is not a solution because now it won’t match State::Succeeded and State::Timeout anymore (maybe it used to work earlier), but this article is more about getting to understand the...
Blog Posts 2016-11-01 ~4 min read
doc.rust-lang.org
pub mod option
...f64) -> Option<f64> { if denominator == 0.0 { None } else { Some(numerator / denominator) } } // The return value of the function is an option let result = divide(2.0, 3.0); // Pattern match to retrieve the value match result { // The division was valid Some(x) => println!("Result: {x}"), // The division was invalid None...
module core Stable since 1.0.0 Version 1.100.0-nightly
academy.fpblock.com
...an uninhabited type (Infallible or a custom enum Never {}), and an exhaustive match over that type. We'll implement this using a macro: macro_rules! absurd { ($x:expr) => { match $x {} }; } This matches the meaning from Haskell: given a value of an uninhabited type, we can produce any type we want...
Miscellaneous 2025-11-19 ~21 min read
docs.rs
...The database can match a font using CSS-like queries. See Database::query . The database can try to load system fonts. Currently, this is implemented by scanning predefined directories. The library does not interact with the system API. Provides a unique ID for each font face. Non-goals Advanced font...
Crate v0.24.0 2026-07-29
github.com
...match *self { AnimationValue::Color(_) => LonghandId::Color, AnimationValue::Height(_) => LonghandId::Height, AnimationValue::TransformOrigin(_) => LonghandId::TransformOrigin, } } } ``` This is not sustainable, as the jump table generated by rustc to compile this huge match expression is larger than 4KB in the final Gecko binary, when this operation could be a trivial `u16` copy. This...
RFC 2363 RFC 2018-03-11 ~4 min read
blog.davimiku.com
...match guardsThe if keyword after the match variable is a match guard. This arm of the match expression is only matched if the match guard is true. We've introduced a new function, tokenize_float. Time to implement this: fn tokenize_float(chars: &Vec<char>, curr_idx: &mut usize) -> Result...
Rust Walkthroughs 2024-11-13 ~43 min read
crates.io
...Example use urlpattern::UrlPattern; use urlpattern::UrlPatternInit; use urlpattern::UrlPatternMatchInput; fn main() { // Create the UrlPattern to match against. let init = UrlPatternInit { pathname: Some("/users/:id".to_owned()), ..Default::default() }; let pattern = <UrlPattern>::parse(init, Default::default()).unwrap(); // Match the pattern against a URL. let url = "https://example.com/users/123...
Crate v0.6.0 2026-02-12
rust-analyzer.github.io
#15118 (first contribution) follow raw pointers in autoderef chain when resolving methods with custom receiver. #15235 (first contribution) don’t insert semicolon when extracting match arm. #15226 make Expand glob import work on enum imports. #15211 support GATs in bounds for associated types. #15223 don’t show unresolved-field diagnostic...
Project/Tooling Updates 2023-07-12 ~1 min read
dystroy.org
...while !(maze.is_won() || maze.is_lost()) { renderer.write(w, &maze)?; w.flush()?; let e = event::read(); match e { Ok(Event::Key(key_event)) => match key_event.into() { key!(q) | key!(ctrl-c) | key!(ctrl-q) => { return Ok(()); } key!(up) => maze.try_move_up(), key!(right) => maze.try_move_right...
Observations/Thoughts 2022-08-03 ~3 min read
github.com
...patterns must use numeric literals for ASCII values, or (for a single byte, not a byte string) cast to char ```rust match buffer[i] { c @ 0x61 .. 0x7A => { /* ... */ } c => { /* ... */ } } match buffer[i] as char { // `c` is of the wrong type! c @ 'a' .. 'z' => { /* ... */ } c => { /* ... */ } } ``` Another option is to change the syntax...
RFC 69 RFC 2014-05-05 ~2 min read
fasterthanli.me
...Sure! But you can match the “scrutinee” (x in match x { ... }) with various patterns, in various “arms” (true => {}, false => {} in the example above). use rand::Rng; fn main() { let msg = match rand::thread_rng().gen_range(0..=10) { // match only 10 10 => "Overwhelming victory", // match anything 5 or above 5...
Observations/Thoughts 2022-02-16 ~42 min read
www.joshmcguigan.com
...In a larger program this type of match pattern would get repeated many times, and this is exactly why the ? operator was introduced. use std::fs::File; fn main() { let file : File = match File::open("filename") { Ok(file) => file, Err(e) => { eprintln!("Error: {}", e); std::process::exit(9); } }; // do something...
News & Blog Posts 2019-02-12 ~5 min read
danielkeep.github.io
...You can only match against literals and grammar constructs which can be captured by macro_rules!. You cannot match unbalanced groups. It is important, however, to keep the macro recursion limit in mind. macro_rules! does not have any form of tail recursion elimination or optimisation. It is recommended that...
Rust Compiler Performance Triage 2022-04-06 ~1 min read
doc.rust-lang.org
pub fn strip_prefix<P>(&self, prefix: P) -> Option<&str>
...Unlike trim_start_matches, this method removes the prefix exactly once. If the string does not start with prefix, returns None. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Examples assert_eq!("foo:bar".strip_prefix...
method core Stable since 1.45.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn strip_suffix<P>(&self, suffix: P) -> Option<&str>
...Unlike trim_end_matches, this method removes the suffix exactly once. If the string does not end with suffix, returns None. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Examples assert_eq!("bar:foo".strip_suffix...
method core Stable since 1.45.0 Version 1.100.0-nightly
doc.rust-lang.org
pub struct RSplitN<'a, T, P>
RSplitN — An iterator over subslices separated by elements that match a predicate function, limited to a given number of splits, starting from the end of the slice. This struct is created by the rsplitn method on slices. Example let slice = [10, 40, 30, 20, 60, 50]; let mut iter = slice...
struct core Stable since 1.0.0 Version 1.100.0-nightly
"I performed an extremely scientific poll on twitter, and determined this is not how it's pronounced ---- Well, it really is `Vec<T, A>`, pronounced ..."

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.