Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
siciarz.net
...fn run(matches: ArgMatches) -> Result<(), String> { // ... match matches.subcommand() { ("analyse", Some(m)) => run_analyse(m, &logger), ("verify", Some(m)) => run_verify(m, &logger), _ => Ok(()), } } fn run_analyse(matches: &ArgMatches, parent_logger: &slog::Logger) -> Result<(), String> { let logger = parent_logger.new(o!("command" => "analyse")); let input = matches.value_of("input-file...
24 Days of Rust 2016-12-20 ~6 min read
github.com
## Summary Change syntax of subslices matching from `..xs` to `xs..` to be more consistent with the rest of the language and allow future backwards compatible improvements. Small example: ```rust match slice { [xs.., _] => xs, [] => fail!() } ``` This is basically heavily stripped version of [RFC 101](https://github.com/rust-lang/rfcs/pull...
RFC 202 RFC 2014-08-15 ~1 min read
matklad.github.io
...char) -> ((), u8) { match op { '+' | '-' => ((), 9), _ => panic!("bad op: {:?}", op), } } fn postfix_binding_power(op: char) -> Option<(u8, ())> { let res = match op { '!' => (11, ()), '[' => (11, ()), _ => return None, }; Some(res) } fn infix_binding_power(op: char) -> Option<(u8, u8)> { let res = match op { '=' => (2, 1), '?' => (4, 3), '+' | '-' => (5, 6), '*' | '/' => (7, 8), '.' => (14, 13...
News & Blog Posts 2020-04-21 ~18 min read
matklad.github.io
...char) -> ((), u8) { match op { '+' | '-' => ((), 9), _ => panic!("bad op: {:?}", op), } } fn postfix_binding_power(op: char) -> Option<(u8, ())> { let res = match op { '!' => (11, ()), '[' => (11, ()), _ => return None, }; Some(res) } fn infix_binding_power(op: char) -> Option<(u8, u8)> { let res = match op { '=' => (2, 1), '?' => (4, 3), '+' | '-' => (5, 6), '*' | '/' => (7, 8), '.' => (14, 13...
News & Blog Posts 2020-05-05 ~18 min read
doc.rust-lang.org
pub struct SplitInclusiveMut<'a, T, P>
SplitInclusiveMut — An iterator over the mutable subslices of the vector which are separated by elements that match pred. Unlike SplitMut, it contains the matched parts in the ends of the subslices. This struct is created by the split_inclusive_mut method on slices. Example let mut v = [10, 40, 30...
struct core Stable since 1.51.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn split_inclusive_mut<F>(&mut self, pred: F) -> SplitInclusiveMut<'_, T, F>
slice::split_inclusive_mut — Returns an iterator over mutable subslices separated by elements that match pred. The matched element is contained in the previous subslice as a terminator. Examples let mut v = [10, 40, 30, 20, 60, 50]; for group in v.split_inclusive_mut(|num| *num % 3 == 0) { let...
method core Stable since 1.51.0 Version 1.100.0-nightly
blog.knoldus.com
...i32) -> i32 { match number { 2 => number, _ => number + 1 , } } const DIGIT: i32 = 9; const RESULT: i32 = even(DIGIT); const RESULT_MATCH: i32 = even_no(DIGIT); fn main() { println!("The result of const function with if statement: {}", RESULT); println!("The result of const function with match statement: {}", RESULT_MATCH); } Output: The result...
Learn Simple Rust 2020-09-30 ~2 min read
rust-lang.github.io
...Adding this hint to enums will force downstream crates to add a wildcard arm to match statements, ensuring that adding new variants is not a breaking change. Adding this hint to structs or enum variants will prevent downstream crates from constructing or exhaustively matching, to ensure that adding new fields...
Updates from Rust Core 2017-11-07 ~12 min read
docs.rs
...grok The grok library allows you to quickly parse and match potentially unstructured data into a structed result. It is especially helpful when parsing logfiles of all kinds. This Rust version is mainly a port from the Java version which in turn drew inspiration from the original Ruby version . Usage...
Crate v2.4.1 2026-03-19
doc.rust-lang.org
...u32) -> List { // `Cons` also has type List Cons(elem, Box::new(self)) } // Return the length of the list fn len(&self) -> u32 { // `self` has to be matched, because the behavior of this method // depends on the variant of `self` // `self` has type `&List`, and `*self` has type `List`, matching on...
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
...Food) -> Option<Food> { match food { Food::CordonBleu => None, _ => Some(food), } } // To make a dish, we need both the recipe and the ingredients. // We can represent the logic with a chain of `match`es: fn cookable_v1(food: Food) -> Option<Food> { match have_recipe(food) { None => None, Some(food) => have_ingredients...
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
pub fn binary_search(&self, x: &T) -> Result<usize, usize>
...If the value is found then Result::Ok is returned, containing the index of the matching element. If there are multiple matches, then any one of the matches could be returned. If the value is not found then Result::Err is returned, containing the index where a matching element could...
method alloc Stable since 1.54.0 Version 1.100.0-nightly
rustc-dev-guide.rust-lang.org
...If you'd like to avoid whitespace normalization and / or if you'd like to match with a regex, use matchesraw instead. matches Usage: //@ matches PATH XPATH PATTERN Checks that the text of each element / attribute / text selected by XPATH in the file given by PATH matches the Python-flavored...
Guide to Rustc Development Book 2024-01-01 ~5 min read
aldaronlau.com
...Match Statements Match statements are my favorite feature of Rust (by far). Doesn't mean they can't be improved though. Someone who is unfamiliar with Rust might write: fn main() { let mut a = 4; match 5 { a => unreachable!(), b => println!("{}", b), } } This code panics (which I still get confused...
Call for Blog Posts 2020-09-30 ~8 min read
doc.rust-lang.org
...let [[x]] = &[&mut [()]]; // x: &() Patterns such as this are said to be using match ergonomics, originally introduced in RFC 2005. Under match ergonomics, as we incrementally match a pattern against a scrutinee, we keep track of the default binding mode. This mode can be one of move, ref mut, or...
The Rust Edition Guide Book 2024-01-01 ~4 min read
doc.rust-lang.org
pub struct SplitInclusive<'a, T, P>
SplitInclusive — An iterator over subslices separated by elements that match a predicate function. Unlike Split, it contains the matched part as a terminator of the subslice. This struct is created by the split_inclusive method on slices. Example let slice = [10, 40, 33, 20]; let mut iter = slice.split_inclusive...
struct core Stable since 1.51.0 Version 1.100.0-nightly
rust-analyzer.github.io
...in "Implement default members" and "Convert #[derive] to manual impl". #15376 make "Convert match to matches!" assist trigger on non-literal bool arms. #15345 don’t provide add_missing_match_arms assist when up-mapping match arm list failed. #15397 remove unwraps from "Generate delegate trait". #15406 don’t provide...
Project/Tooling Updates 2023-08-09 ~1 min read
doc.rust-lang.org
pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<'_, T, F>
slice::rsplit_mut — Returns an iterator over mutable subslices separated by elements that match pred, starting at the end of the slice and working backwards. The matched element is not contained in the subslices. Examples let mut v = [100, 400, 300, 200, 600, 500]; let mut count = 0; for group...
method core Stable since 1.27.0 Version 1.100.0-nightly
doc.rust-lang.org
...rust 1.65 🛈 you can target specific edition by compiling like this rustc --edition=2021 main.rs With let-else, a refutable pattern can match and bind variables in the surrounding scope like a normal let, or else diverge (e.g. break, return, panic!) when the pattern doesn't...
Rust by Example Book 2024-01-01 ~1 min read
doc.rust-lang.org
pub fn splitn<F>(&self, n: usize, pred: F) -> SplitN<'_, T, F>
slice::splitn — Returns an iterator over subslices separated by elements that match pred, limited to returning at most n items. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice. Examples Print the slice split once by numbers...
method core Stable since 1.0.0 Version 1.100.0-nightly
"We are living through Rust finding its more "complete" form while still being an actually useful production language."

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.