Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
github.com
...Needs filling in. ### Multiple branches All of these matches are equivalent, each written in a different style: ```rust use E::*; enum E { A, B, C, D } match foo { A | B => println!("Give me A | B!"), C | D => println!("Give me C | D!"), } match foo { | A | B => println!("Give me A...
RFC 1925 RFC 2017-02-23 ~4 min read
docs.rs
...Usage let matcher = regex_filtered::Builder::new() .push("foo")? .push("bar")? .push("baz")? .push("quux")? .build()?; assert!(matcher.is_match("bar")); assert_eq!(matcher.matching("baz").count(), 1); assert_eq!(matcher.matching("foo quux").count(), 2); # Ok::<(), Box<dyn std::error::Error>>(()) [ Regexes::is_match ] returns whether any pattern in...
Crate v0.2.1 2026-03-22
crates.io
Simple string matching with single- and multi-character wildcard operator. wildmatch Match strings against a simple wildcard pattern. Tests a wildcard pattern p against an input string s . Returns true only when p matches the entirety of s . See also the example described on wikipedia for matching wildcards. ? matches exactly...
Crate v2.6.1 2025-11-14
github.com
## Summary [summary]: #summary Better ergonomics for pattern-matching on references. Currently, matching on references requires a bit of a dance using `ref` and `&` patterns: ```rust let x: &Option<_> = &Some(0); match x { &Some(ref y) => { ... }, &None => { ... }, } // or using `*`: match *x { Some(ref x) => { ... }, None => { ... }, } ``` After this RFC, the above form...
RFC 2005 RFC 2016-08-12 ~12 min read
doc.rust-lang.org
pub fn trim_right_matches<P>(&self, pat: P) -> &str
str::trim_right_matches — Returns a string slice with all suffixes that match a pattern repeatedly removed. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Text directionality A string is a sequence of bytes. 'Right' in...
method core Stable since 1.0.0 Version 1.100.0-nightly
github.com
## Summary [summary]: #summary Allow `if let` guards in `match` expressions. ## Motivation [motivation]: #motivation This feature would greatly simplify some logic where we must match a pattern iff some value computed from the `match`-bound values has a certain form, where said value may be costly or impossible (due to affine...
RFC 2294 RFC 2018-01-15 ~5 min read
doc.rust-lang.org
pub fn trim_end_matches<P>(&self, pat: P) -> &str
str::trim_end_matches — Returns a string slice with all suffixes that match a pattern repeatedly removed. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Text directionality A string is a sequence of bytes. end in...
method core Stable since 1.30.0 Version 1.100.0-nightly
doc.rust-lang.org
The match Control Flow Construct Rust has an extremely powerful control flow construct called match that allows you to compare a value against a series of patterns and then execute code based on which pattern matches. Patterns can be made up of literal values, variable names, wildcards, and many other...
The Rust Programming Language Book 2024-02-01 ~9 min read
doc.rust-lang.org
pub fn trim_left_matches<P>(&self, pat: P) -> &str
str::trim_left_matches — Returns a string slice with all prefixes that match a pattern repeatedly removed. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Text directionality A string is a sequence of bytes. 'Left' in...
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn trim_start_matches<P>(&self, pat: P) -> &str
str::trim_start_matches — Returns a string slice with all prefixes that match a pattern repeatedly removed. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Text directionality A string is a sequence of bytes. start in...
method core Stable since 1.30.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn matches<P>(&self, pat: P) -> Matches<'_, P>
str::matches — Returns an iterator over the disjoint matches of a pattern within the given string slice. The pattern can be a &str, char, a slice of chars, or a function or closure that determines if a character matches. Iterator behavior The returned iterator will be a DoubleEndedIterator if the...
method core Stable since 1.2.0 Version 1.100.0-nightly
smallcultfollowing.com
...Void) { match v { } } In effect, this match serves as a kind of assertion. You are saying “because v can never be instantiated, foo could never actually be called, and therefore – when I match against it – this match must be dead code”. Since the match is dead code, you don’t...
News & Blog Posts 2018-08-14 ~14 min read
github.com
## Summary Change array/slice patterns in the following ways: - Make them only match on arrays (`[T; n]` and `[T]`), not slices; - Make subslice matching yield a value of type `[T; n]` or `[T]`, not `&[T]` or `&mut [T]`; - Allow multiple mutable references to be made to different parts of the...
RFC 495 RFC 2014-12-03 ~3 min read
doc.rust-lang.org
...For example, these two matches on x: &i32 are equivalent: let int_reference = &3; let a = match *int_reference { 0 => "zero", _ => "some" }; let b = match int_reference { &0 => "zero", _ => "some" }; assert_eq!(a, b); The grammar production for reference patterns has to match the token && to match a reference to...
The Rust Reference Book 2024-01-01 ~26 min read
www.ncameron.org
...For example, if we have a pattern ab?c and a single match which has matched a in the input then we can fork and one match will attempt to match b then c, and one will just match c. One interesting aspect of matching is handling metavariable matching in...
News & Blog Posts 2019-01-22 ~4 min read
doc.rust-lang.org
if let For some use cases, when matching enums, match is awkward. For example: // Make `optional` of type `Option<i32>` let optional = Some(7); match optional { Some(i) => println!("This is a really long string and `{:?}`", i), _ => {}, // ^ Required because `match` is exhaustive. Doesn't it seem // like wasted space? }; if...
Rust by Example Book 2024-01-01 ~2 min read
xion.io
Rust is one of those nice languages with pattern matching. If you don’t know, it can be thought of as a generalization of the switch statement: comparing objects not just by value (or overloaded equality operator, etc.) but by structure: match hashmap.get(&key) { Some(value) => do_something_with...
News & Blog Posts 2016-06-06 ~5 min read
doc.rust-lang.org
...match Arms As discussed in Chapter 6, we use patterns in the arms of match expressions. Formally, match expressions are defined as the keyword match, a value to match on, and one or more match arms that consist of a pattern and an expression to run if the value matches...
The Rust Programming Language Book 2024-02-01 ~7 min read
crates.io
...let mut router = Router::new(); router.insert("/{{hello}}", true)?; router.insert("/{hello}", true)?; // Match the static route. let matched = router.at("/{hello}")?; assert!(matched.params.is_empty()); // Match the dynamic route. let matched = router.at("/hello")?; assert_eq!(matched.params.get("hello"), Some("hello")); Conflict Rules Static and dynamic route...
Crate v0.9.2 2026-04-08
crates.io
...extern crate clap; extern crate sys_mount; use clap::{App, Arg}; use sys_mount::{Mount, MountFlags, SupportedFilesystems}; use std::process::exit; fn main() { let matches = App::new("mount") .arg(Arg::with_name("source").required(true)) .arg(Arg::with_name("directory").required(true)) .get_matches(); let src = matches.value_of("source...
Crate v3.1.0 2026-01-29
"Why do I use the letter ‘o’ for my generic closure param name? [...] I recently realized that since Rust uses pipes to enclose a param block, usin..."

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.