Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
rust-lang.github.io
...R) -> <R as Residual<T>>::TryType { FromResidual::from_residual(r) } match Try::branch(x) { ControlFlow::Continue(v) => v, ControlFlow::Break(r) => break 'try make_try_type(r), } This still uses FromResidual::from_residual to actually create the value, but determines the type to return from the argument via the Residual...
RFC 3721 RFC 2024-02-22 ~19 min read
rust-lang.github.io
...If the type ascription expression is in reference context, then we require the ascribed type to exactly match the type of the expression, i.e., neither subtyping nor coercion is allowed. These reference contexts are as follows (where <expr> is a type ascription expression): &[mut] <expr> let ref [mut] x...
RFC 803 RFC 2015-02-03 ~6 min read
rust-lang.github.io
...Some solutions: • Punctuation(char) with special rules for pattern matching tokens, • Punctuation([char]) with a facility for macros to split tokens. Tokenising could match the maximum number of punctuation characters, or use the rules for the current token set. The former would have issues with pattern matching. The latter is...
RFC 1566 RFC 2016-02-15 ~16 min read
rust-lang.github.io
...Generic associated consts in match patterns It seems desirable to allow constants that depend on type parameters in match patterns, but it's not clear how to do so while still checking exhaustiveness and reachability of the match arms. Most likely this requires new forms of where clause, to constrain...
RFC 195 RFC 2014-08-04 ~36 min read
rust-lang.github.io
...Vec<_> = iter::repeat(elem).take(n).collect(); None of these quite match the convenience, power, and performance of: let vec = Vec::from_elem(elem, n) • #1 is verbose and slow, because each push requires a capacity check. • #2 only works for a Copy elem and const n. • #3 needs a...
RFC 832 RFC 2015-02-11 ~2 min read
rust-lang.github.io
...It is a simple method with an obvious implementation, but it provides convenience while working with string segmentation manually, which we already have ample tools for (for example the method find that returns the first matching byte offset). Using split_at can lead to less repeated bounds checks, since it...
RFC 1123 RFC 2015-05-17 ~2 min read
rust-lang.github.io
...The lint trivial_constraints would be added, matching the pre-1.7 semantics of E0193, and would be set to warn by default. How We Teach This This feature does not need to be taught explicitly. Knowing the basic rules of where clauses, one would naturally already expect this to...
RFC 2056 RFC 2017-07-05 ~2 min read
rust-lang.github.io
...SomeTrait does not implement SomeTrait" - no indication that the non-object-safe method were to blame, only a failure in trait matching. Another advantage of this proposal is that it implies that all method-calls can always be rewritten into an equivalent UFCS call. This simplifies the "core language" and...
RFC 255 RFC 2014-09-22 ~6 min read
rust-lang.github.io
...for x in it.take(3) { // a *copy* of the iterator is used here // .. } match it.next() { // the original iterator (not advanced) is used here // .. } However, there is considerable demand for Copy range types for multiple reasons: • ergonomic use without needing explicit .clone()s or rewriting the a..b syntax...
RFC 3550 RFC 2023-12-18 ~17 min read
rust-lang.github.io
...In the absence of catch, we would have to suggest the introduction of a match block. Extended error message text. In the extended error message, for those cases where the return type cannot easily be changed, we might consider suggesting that the fallible portion of the code is refactored into...
RFC 1859 RFC 2017-01-19 ~14 min read
rust-lang.github.io
...if input > max { max } else if input < min { min } else { input } and input.max(min).min(max); and even match input { c if c > max => max, c if c < min => min, c => c, } Typically these patterns exist where there is a need to interface with APIs that take normalized values...
RFC 1961 RFC 2017-03-26 ~2 min read
rust-lang.github.io
...Note that we do not perform coercions when matching traits (except for receivers, see below). If there is an impl for some type U, and T coerces to U, that does not constitute an implementation for T. For example, the following will not type check, even though it is OK...
RFC 401 RFC 2014-10-30 ~14 min read
rust-lang.github.io
...Eventually, we will likely want to support fully general pattern matching just like in let bindings (e.g., const (a, b): (u8, u8) = (1, 1)) to not have const _ be a special case in the language. However, this RFC leaves the details of such a design up to a future...
RFC 2526 RFC 2018-08-18 ~2 min read
rust-lang.github.io
...One can expect the ability to match tuple variants like V(u8, u8, u8) with patterns like V(x, ..) or V(.., z), but the compiler rejects such patterns currently despite accepting very similar V(..). This RFC is intended to "complete" the feature and make it work in all possible list...
RFC 1492 RFC 2016-02-06 ~2 min read
rust-lang.github.io
...let packed_cast = &raw const packed.field; Reference-level explanation Rust contains two operators that perform place-to-value conversion (matching & in C): one to create a reference (with some given mutability) and one to create a raw pointer (with some given mutability). In the MIR, this is reflected as...
RFC 2582 RFC 2018-11-01 ~11 min read
rust-lang.github.io
...STRICT_KEYWORD | RESERVED_KEYWORD ; fragment STRICT_KEYWORD : 'as' | 'box' | 'break' | 'continue' | 'crate' | 'else' | 'enum' | 'extern' | 'fn' | 'for' | 'if' | 'impl' | 'in' | 'let' | 'loop' | 'match' | 'mod' | 'mut' | 'once' | 'proc' | 'pub' | 'ref' | 'return' | 'self' | 'static' | 'struct' | 'super' | 'trait' | 'true' | 'type' | 'unsafe' | 'use' | 'virtual' | 'while' ; fragment RESERVED_KEYWORD : 'alignof' | 'be' | 'const' | 'do' | 'offsetof' | 'priv...
RFC 90 RFC 2014-05-23 ~3 min read
github.com
...This is now widely considered to be a mistake, because it makes implementing `Copy` for those types hazardous due to how the two traits interact. ```rust for x in it.take(3) { // a *copy* of the iterator is used here // .. } match it.next() { // the original iterator (not advanced) is used...
RFC 3550 RFC 2023-12-18 ~18 min read
rust-lang.github.io
...affect termination, which has no practical value, thus remaining unimplemented • although more useful than loops, conditional control flow (if/else and match) also remains unimplemented and only match would pose a challenge • immutable let bindings in blocks have the same status and implementation difficulty as if/else and they both...
RFC 911 RFC 2015-02-25 ~7 min read
rust-lang.github.io
...const fn parse_bool(s: &str) -> bool { match s { "true" => true, "false" => false, other => panic!("`{}` is not a valid bool", other), } } parse_bool("true"); parse_bool("false"); parse_bool("foo"); will produce an error with your custom error message: error[E0080]: `foo` is not a valid bool --> src/main.rs...
RFC 2345 RFC 2018-02-22 ~2 min read
rust-lang.github.io
...satisfied wherever the struct or enum is used with actual type parameters. Motivation Makes type checking saner. Catches errors earlier in the development process. Matches behaviour with built-in bounds (I think). Currently formal type variables in traits and functions may have bounds and these bounds are checked whenever the...
RFC 34 RFC 2014-04-05 ~2 min read
"It's a great example of the different attitudes of C/C++ and Rust: In C/C++ something is correct when someone can use it correctly, but in Rust someth..."

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.