Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
crates.io
Statically assert that a type matches another type assert_type_match A niche utility macro to statically assert that a type matches another type. Purpose The primary purpose of this crate is to make copying and pasting types from other crates into your own more future-proof by statically asserting...
Crate v0.1.1 2024-09-23
rust-lang.github.io
Summary Various changes to the match ergonomics rules: • On edition ≥ 2024, & and &mut patterns only remove a single layer of references. • On edition ≥ 2024, mut on an identifier pattern does not force its binding mode to by-value. • On all editions, & patterns can match against &mut references. • On all editions...
RFC 3627 RFC 2024-05-06 ~14 min read
docs.rs
Regex matching on character and byte streams. matchers Regular expression matching on Rust streams. Overview The regex crate implements regular expression matching on strings and byte arrays. However, in order to match the output of implementations of fmt::Debug and fmt::Display , or by any code which writes to an...
Crate v0.2.0 2024-07-01
doc.rust-lang.org
...fn age() -> u32 { 15 } fn main() { println!("Tell me what type of person you are"); match age() { 0 => println!("I haven't celebrated my first birthday yet"), // Could `match` 1 ..= 12 directly but then what age // would the child be? // Could `match` n and use an `if` guard, but would...
Rust by Example Book 2024-01-01 ~1 min read
rust-lang.github.io
...Like the for loop before it, this construct can be transformed in a syntax-lowering pass into the equivalent match statement. The expression is given to match and the pattern becomes a match arm. If there is an else block, that becomes the body of the _ => {} arm, otherwise _ => {} is provided...
RFC 160 RFC 2014-08-26 ~4 min read
trifectatech.org
...when #[loop_match] and #[const_continue] are configured out (e.g. with #[cfg_attr(feature = "loop_match", loop_match)]), the code behaves like before. Benchmarks So, how much does this help? As always, it depends. Your algorithm must actually look like a loop with a match to benefit at all...
Observations/Thoughts 2025-09-10 ~9 min read
xd009642.github.io Archived: primary link replaced with an archive on 2026-09-12T17:24:55.139Z (UTC; replacement date, not snapshot date)
...impl Match for BinaryStreamMatcher { fn temporal_match(&self, match_state: &mut MatchState) -> Option<bool> { let json = ValidJsonMatcher; let len = match_state.len(); let last = match_state.last(); if len == 1 && json.unary_match(last).unwrap() { match_state.keep_message(0); Some(true) } else if last.is_binary() { // We won't...
Project/Tooling Updates 2025-03-05 ~3 min read
rust-lang.github.io
...Foo(x) • The left side of a match arm, i.e. Foo(x) | Bar(x) if x > 5 • An entire match arm, i.e. Foo(x) | Bar(x) if x > 5 => 1 This RFC proposes only the first of these, but the others would be more useful in some cases...
RFC 85 RFC 2014-05-21 ~1 min read
sailor.li
...running 3 tests test accursed_match ... bench: 1,681.19 ns/iter (+/- 245.20) test optimised_match ... bench: 1,681.06 ns/iter (+/- 261.87) test regular_match ... bench: 2,339.23 ns/iter (+/- 74.51) Using arrays of [0u8; 16384]: test accursed_match ... bench: 9,373.10 ns/iter...
Rust Walkthroughs 2025-08-27 ~5 min read
rust-lang.github.io
...if let A(x) = expr { do_stuff_with(x); } else if let B(x) = expr { do_stuff_with(x); } or, using match: match expr { A(x) | B(x) => do_stuff_with(x), _ => {}, } This way of using match is seen multiple times in std::iter when dealing with the Chain iterator...
RFC 2175 RFC 2017-10-16 ~7 min read
systemf.epfl.ch
...The brown lookbehind has n = 1 since it always matches exactly 1 character. m = 2 because that is the shortest matching length of aa. The blue lookbehind has n = 2 since it always matches exactly 2 characters. The surrounding lookbehinds do not contribute to the match length. m = 1 because...
Observations/Thoughts 2025-07-16 ~27 min read
adventures.michaelfbryan.com
Rust 1.26 introduced a nifty little feature called Basic Slice Patterns which lets you pattern match on slices with a known length. Later on in Rust 1.42, this was extended to allow using .. to match on “everything else”. As features go this may seem like a small addition...
Rust Walkthroughs 2021-08-18 ~3 min read
graphallthethings.com
...Column) -> Vec<u8> { match column { Column::I32(values) => compress_generic(values), Column::F32(values) => compress_generic(values), Column::String(values) => compress_generic(values), ... } } Something like that! Match clauses everywhere! Extremely tedious to work with. Eventually I closed shop on PancakeDB (entirely because of the match clauses, of course), but I...
Rust Walkthroughs 2024-11-20 ~4 min read
rust-lang.github.io
Summary Permit matching sub-slices and sub-arrays with the syntax ...Binding a variable to the expression matched by a subslice pattern can be done using syntax <IDENT> @ .. similar to the existing <IDENT> @ <PAT> syntax, for example: // Binding a sub-array: let [x, y @ .., z] = [1, 2, 3, 4]; // `y...
RFC 2359 RFC 2018-03-08 ~8 min read
blog.sheerluck.dev
In this post, we are going to learn about structs, enums and pattern matching in Rust. Once we cover all these concepts, we will build a JSON Parser in Rust from scratch. I'm really excited about this project. Let's start. Get the source code from here Structs in...
Rust Walkthroughs 2026-04-29 ~43 min read
rust-lang.github.io
...Lastly, there are alternatives that don't seem very favorable, but are listed for completeness sake: • Remove unsafe from the API by returning a special SubSlice<'a> type instead of (uint, uint) in each match, that wraps the haystack and the current match as a (*start, *match_start, *match_end...
RFC 528 RFC 2015-02-17 ~15 min read
doc.rust-lang.org
...let Config { window_width, window_height } = config; let Token = token; let Id(id_number) = id; let error = Error::Other; let message = Message::Reaction(3); // Non-exhaustive enums can be matched on exhaustively within the defining crate. match error { Error::Message(ref s) => { }, Error::Other => { }, } match message { // Non-exhaustive variants can...
The Rust Reference Book 2024-01-01 ~4 min read
doc.rust-lang.org
pub fn split<F>(&self, pred: F) -> Split<'_, T, F>
slice::split — Returns an iterator over subslices separated by elements that match pred. The matched element is not contained in the subslices. Examples let slice = [10, 40, 33, 20]; let mut iter = slice.split(|num| num % 3 == 0); assert_eq!(iter.next().unwrap(), &[10, 40]); assert_eq!(iter.next().unwrap...
method core Stable since 1.0.0 Version 1.100.0-nightly
audunhalland.github.io
...Note that the matching!() macro uses pattern matching by default. Printing a Debug-based diff on a pattern mismatch might not produce a good diff output, since patterns could be much smaller than the actuall value due to spreads or other variations in syntax. matching!() now also supports matching using...
Project/Tooling Updates 2022-11-30 ~3 min read
docs.rs
...clap_complete_command::Shell, }, } fn main() { let cli = Cli::parse(); match cli.command { // e.g. `$ cli completions bash` Commands::Completions { shell } => { shell.generate(&mut Cli::command(), &mut std::io::stdout()); } } } Builder use clap::{Arg, Command}; fn build_cli() -> Command { Command::new(env!("CARGO_PKG_NAME")) .subcommand_required(true) .subcommand( Command...
Crate v0.6.1 2024-07-14
"I *do* rather hope anyone using `-Zllvm-target-features` or any stabilized form thereof would know that they are getting a conversation with the drago..."

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.