Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
rust-lang.github.io
...Adding a dependency To depend on a library hosted on crates.io, you modify hello_world.rs: #!/usr/bin/env cargo //! ```cargo //! [dependencies] //! regex = "1.8.0" //! ``` fn main() { let re = Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap(); println!("Did our date match? {}", re.is_match("2014...
RFC 3424 RFC 2023-04-26 ~16 min read
rust-lang.github.io
...After src/grammar transitions into this state, for any discovered discrepancies the rustc parser implementation must be adjusted to match the src/grammar, unless decided otherwise by the RFC process. RFC process changes for syntactic changes and additions Once the src/grammar enters semi-canonical state, all RFCs must describe...
RFC 1331 RFC 2015-10-21 ~2 min read
rust-lang.github.io
...Drawbacks • The compiler has less flexibility with respect to discriminant computation and pattern matching optimizations when a type is niche-optimized. Rationale and alternatives It's always possible to not strengthen the guarantees of the language. Prior art The compiler already supports Option being combined with specific non-zero types...
RFC 3391 RFC 2023-04-18 ~3 min read
rust-lang.github.io
...offset(offset as isize) as *const usize); let v = *(ptr.offset((offset + usize_bytes) as isize) as *const usize); // break if there is a matching byte let zu = contains_zero_byte(u ^ repeated_x); let zv = contains_zero_byte(v ^ repeated_x); if zu || zv { break; } } offset += usize_bytes * 2...
RFC 2043 RFC 2017-06-20 ~7 min read
rust-lang.github.io
...0 }; match t { Alias::Bar(_i) => {} Alias::Baz { i: _i } => {} } } Reference-level explanation If a path refers into an alias, the behavior for enum variants should be as if the alias was substituted with the original type. Here are some examples of the new behavior in edge cases: type Alias...
RFC 2338 RFC 2018-02-15 ~3 min read
rust-lang.github.io
...Ok(()) } fn main() -> () { use std::process::exit; use libc::{EXIT_SUCCESS, EXIT_FAILURE}; exit(match inner_main() { Ok(_) => EXIT_SUCCESS, Err(ref err) => { let progname = get_program_name(); eprintln!("{}: {}\n", progname, err); EXIT_FAILURE } }) } These problems can be solved by generalizing the return type of main and test functions. Detailed...
RFC 1937 RFC 2017-02-22 ~21 min read
rust-lang.github.io
...Patterns Today, a static is allowed to be used in pattern matching. With the introduction of const, however, a static will be forbidden from appearing in a pattern match, and instead only a const can appear. Drawbacks This RFC introduces two keywords for global data. Global data is kind of...
RFC 246 RFC 2014-08-08 ~8 min read
rust-lang.github.io
...This brings with it a number of benefits: • The internal structure can evolve over time to better fit new platforms while being backwards compatible. • This design matches what one would expect from C, where there's only a flat namespace available. • Finding an API is quite easy as the answer...
RFC 1291 RFC 2015-09-21 ~12 min read
rust-lang.github.io
...The primary proposal is arbitrary order, to match preexisting BinaryHeap iterators. Unresolved questions • Concrete shape of the BTreeMap API is not resolved here • Will closed ranges be used for the drain API?
RFC 1257 RFC 2015-08-14 ~3 min read
rust-lang.github.io
...F) -> Option<T> { let mut foo = unsafe { mem::uninitialized::<T>() }; let mut foo_ref = &mut foo as *mut T; match std::panic::catch_unwind(|| { let val = f(); unsafe { ptr::write(foo_ref, val); } }) { Ok(()) => Some(foo); Err(_) => None } } Naively, this code might look safe. The problem though is that by...
RFC 1892 RFC 2017-02-09 ~8 min read
rust-lang.github.io
...Data (such as from the network) is rarely guaranteed to be ASCII only, nor is it desirable to remove or replace non-ASCII bytes, even if ASCII-range-only operations are used. (For example, ASCII case-insensitive matching is common in HTML and CSS.) Every single use of the Ascii...
RFC 486 RFC 2014-11-27 ~3 min read
rust-lang.github.io
...The specific declarative syntax using pattern matching and templating is often referred to as 'macros by example'. 'Pattern macro' has been suggested as an alternative for 'declarative macro'. Drawbacks There is a risk that macro_rules! is good enough for most users and there is low adoption of the new...
RFC 1584 RFC 2016-04-17 ~3 min read
rust-lang.github.io
...Rather, the trait matching system implicitly instantiates impls as part of trait matching. This implies that all type parameters are always instantiated with type variables. These type variables are assigned fallbacks according to the defaults given. Type variables with fallbacks We extend the inference system so that when a type...
RFC 213 RFC 2015-02-04 ~18 min read
rust-lang.github.io
...Humans comprehend information through pattern matching. By ensuring that all Rust code has similar formatting, less mental effort is required to comprehend a new project, lowering the bar to entry for new developers. Thus, there are productivity benefits to using a formatting tool (such as rustfmt), and even larger benefits...
RFC 2436 RFC 2018-05-04 ~3 min read
github.com
...Ok(()) } fn main() -> () { use std::process::exit; use libc::{EXIT_SUCCESS, EXIT_FAILURE}; exit(match inner_main() { Ok(_) => EXIT_SUCCESS, Err(ref err) => { let progname = get_program_name(); eprintln!("{}: {}\n", progname, err); EXIT_FAILURE } }) } ``` These problems can be solved by generalizing the return type of `main` and test functions. [csv...
RFC 1937 RFC 2017-02-22 ~21 min read
rust-lang.github.io
...IntoIterator<Item = u8>> Iterator for RlEncode<I> { type Item = u8; fn next(&mut self) -> Option<Self::Item> { let xs = self.xs.get_or_insert_with(|| unsafe { self.into_xs.take().unwrap_unchecked().into_iter() }); if let Some(x) = self.yield_x.take() { return Some(x); } loop { match (xs.next(), self...
RFC 3513 RFC 2023-10-10 ~19 min read
rust-lang.github.io
...Detailed design New atomic types The AtomicI8, AtomicI16, AtomicI32, AtomicI64 and AtomicI128 types are added along with their matching AtomicU* type. These have the same API as the existing AtomicIsize and AtomicUsize types. Note that support for 128-bit atomics is dependent on the i128/u128 RFC being accepted. Target...
RFC 1543 RFC 2016-03-14 ~3 min read
rust-lang.github.io
...The compiler will insert a call to the va_start intrinsic at the start of the function to provide the VaList argument (if used), and a matching call to the va_end intrinsic on any exit from the function. The implementation of VaList::arg will call va_arg. The implementation...
RFC 2137 RFC 2017-08-21 ~8 min read
rust-lang.github.io
...It is slightly better if structs had a specified-but-C-incompatible layout, and one has control over the C interface, because then one can manually arrange the fields in the C definition to match the Rust order. That said, this scenario requires: • Needing to pass a Rust struct into...
RFC 79 RFC 2014-05-17 ~3 min read
rust-lang.github.io
...Then during compilation, this information is used at the proper places rather than matching against an enum listing the OSes we recognize. The target_os, target_family, and target_arch cfg variables would be extracted from the --target passed to rustc. Drawbacks More complexity. However, this is very flexible and...
RFC 131 RFC 2014-06-18 ~3 min read
"Using (traits) for Inheritance was like putting car wheels on a boat because I am used to driving a vehicle with wheels."

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.