Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
rust-lang.github.io
Summary Currently when using an if let statement and an irrefutable pattern (read always match) is used the compiler complains with an E0162: irrefutable if-let pattern. The current state breaks macros who want to accept patterns generically and this RFC proposes changing this error to an error-by-default...
RFC 2086 RFC 2017-07-27 ~1 min read
rust-lang.github.io
...Finally, it is useful for the reader to keep in mind that according to the definitions of this RFC, no simple NT matches the empty fragment, and likewise no token matches the empty fragment of Rust syntax. (Thus, the only NT that can match the empty fragment is a complex...
RFC 550 RFC 2014-12-21 ~21 min read
rust-lang.github.io
Summary Add a lifetime specifier for macro_rules! patterns, that matches any valid lifetime. Motivation Certain classes of macros are completely impossible without the ability to pass lifetimes. Specifically, anything that wants to implement a trait from inside of a macro is going to need to deal with lifetimes eventually...
RFC 1590 RFC 2016-04-22 ~1 min read
rust-lang.github.io
Summary Add a literal fragment specifier for macro_rules! patterns that matches literal constants: macro_rules! foo { ($l:literal) => ( /* ... */ ); }; Motivation There are a lot of macros out there that take literal constants as arguments (often string constants). For now, most use the expr fragment specifier, which is fine since literal...
RFC 1576 RFC 2016-04-08 ~2 min read
rust-lang.github.io
...Optional match sugar Originally, the RFC included the ability to match the errors caught by a catch by writing catch { .. } match { .. }, which could be translated as follows: • Construct: catch { foo()?.bar() } match { A(a) => baz(a), B(b) => quux(b) } Shallow: match (catch { foo()?.bar() }) { Ok(a) => a, Err(e...
RFC 243 RFC 2014-09-16 ~20 min read
github.com
## Summary [summary]: #summary Currently when using an if let statement and an irrefutable pattern (read always match) is used the compiler complains with an `E0162: irrefutable if-let pattern`. The current state breaks macros who want to accept patterns generically and this RFC proposes changing this error to an error...
RFC 2086 RFC 2017-07-27 ~2 min read
rust-lang.github.io
...For instance, the following is an erroneous use of the match keyword: fn match(needle: &str, haystack: &str) -> bool { haystack.contains(needle) } error: expected identifier, found keyword `match` --> src/lib.rs:1:4 | 1 | fn match(needle: &str, haystack: &str) -> bool { | ^^^^^ It can instead be written as fn r#match...
RFC 2151 RFC 2017-09-14 ~4 min read
rust-lang.github.io
Summary Tuple structs can now be constructed and pattern matched with Self(v1, v2, ..). A simple example: struct TheAnswer(usize); impl Default for TheAnswer { fn default() -> Self { Self(42) } } Similarly, unit structs can also be constructed and pattern matched with Self. Motivation This RFC proposes a consistency fix allowing Self...
RFC 2302 RFC 2017-01-18 ~6 min read
github.com
## Summary [summary]: #summary Tuple `struct`s can now be constructed and pattern matched with `Self(v1, v2, ..)`. A simple example: ```rust struct TheAnswer(usize); impl Default for TheAnswer { fn default() -> Self { Self(42) } } ``` Similarly, unit structs can also be constructed and pattern matched with `Self`. ## Motivation [motivation]: #motivation This RFC...
RFC 2302 RFC 2017-01-18 ~7 min read
github.com
...expected identifier, found keyword `match` --> src/lib.rs:1:4 | 1 | fn match(needle: &str, haystack: &str) -> bool { | ^^^^^ ``` It can instead be written as `fn r#match(needle: &str, haystack: &str)`, using the `r#match` raw identifier, and the compiler will accept this as a true `match` function. Generally when...
RFC 2151 RFC 2017-09-14 ~5 min read
rust-lang.github.io
...Checks for exhaustiveness work identically to matches on structures with named fields. For instance, if the above match omitted the last case, it would receive a warning for a non-exhaustive match. A pattern must include a .. if it does not match all fields, other than union fields for which...
RFC 2102 RFC 2017-08-05 ~18 min read
rust-lang.github.io
...patterns must use numeric literals for ASCII values, or (for a single byte, not a byte string) cast to char 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 so...
RFC 69 RFC 2014-05-05 ~2 min read
rust-lang.github.io
...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
rust-lang.github.io
...Rust already allows similar syntax for destructuring in pattern matches: a pattern match can use SomeStruct { field1, field2 } => ... to match field1 and field2 into values with the same names. This RFC introduces symmetrical syntax for initializers. A family of related structures will often use the same field name for a...
RFC 1682 RFC 2016-07-18 ~6 min read
rust-lang.github.io
...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-lang.github.io
Summary Provide a simple model describing three kinds of structs and variants and their relationships.Provide a way to match on structs/variants in patterns regardless of their kind (S{..}).Permit tuple structs and tuple variants with zero fields (TS()). Motivation There's some mental model lying under the current...
RFC 1506 RFC 2016-02-07 ~5 min read
rust-lang.github.io
...This lint warns when you use print!() with a format string that ends in a newline. • match_ref_pats: Checks for matches where all arms match a reference, suggesting to remove the reference and deref the matched expression instead. It also checks for if let &foo = bar blocks. • ptr_arg...
RFC 2476 RFC 2018-06-14 ~30 min read
rust-lang.github.io
...These two variants correspond to concrete types for when the key matched something in the map, and when the key didn't, respectively. If there isn't a match, the user has exactly one option: insert a value using set, which will also insert the guarantor, and destroy the Entry...
RFC 216 RFC 2014-08-28 ~7 min read
rust-lang.github.io
...This proposal also includes a debug_asset_ne, matching debug_assert_eq. Motivation This feature, among other reasons, makes testing more readable and consistent as it complements asset_eq. It gives the same style panic message as assert_eq, which eliminates the need to write it yourself. Detailed design This...
RFC 1653 RFC 2016-07-27 ~1 min read
rust-lang.github.io
...Result<!, E>) -> Self { match x { Err(e) => Err(From::from(e)), } } } But Option doesn't need to do anything exciting, so just has a simple implementation, taking advantage of the default parameter: impl<T> FromResidual for Option<T> { fn from_residual(x: Self::Residual) -> Self { match x { None => None, } } } In...
RFC 3058 RFC 2020-12-12 ~39 min read
"the compiler usually doesn't complain about \[you\] doing undefined behavior because it doesn't know that you're doing undefined behavior."

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.