rust-lang.github.io
...K,
) -> &'r mut V {
match map.get_mut(&key) { // ──────────────────┐ 'r only needs to
Some(value) => value, // ◄────┘ be valid here...
None => { // │
map.insert(key, V::default()); // │
// ^~~~~~ ERROR // │
map.get_mut(&key).unwrap() // │
} // │
} // │ ...but today it covers
} // ◄────┘ all this
Under Polonius Alpha, this code compiles.
Polonius Alpha is part of a larger...
RFC 3935
RFC
2026-02-23
~53 min read
rust-lang.github.io
...By renaming Rust's unsafe pointers to closely match their C brethren, the likelihood for erroneously transcribing a signature is diminished.
Detailed design
This section will assume that the current unsafe pointer design is forgotten completely, and will explain the unsafe pointer design from scratch.
There are two unsafe pointers...
RFC 68
RFC
2014-06-11
~5 min read
rust-lang.github.io
...trait Trait {
fn foo(&self) -> impl Sized;
}
impl Trait for () {
fn foo(&self) -> () {}
//~^ WARN impl trait in impl method signature does not match
//~| trait method signature
//~| NOTE add `#[allow(refining_impl_trait)]` if it is intended
//~| for this to be part of the public API of this crate
//~| NOTE we...
RFC 3617
RFC
2024-04-03
~37 min read
github.com
## Summary
[summary]: #summary
`c"…"` string literals.
## Motivation
[motivation]: #motivation
Looking at the [amount of `cstr!()` invocations just on GitHub](https://cs.github.com/?scopeName=All+repos&scope=&q=cstr%21+lang%3Arust) (about 3.2k files with matches) it seems like C string literals
are a widely used feature. Implementing...
RFC 3348
RFC
2022-11-15
~5 min read
rust-lang.github.io
...Rationale and alternatives
Chosen design
This design pretty much matches how C compilers implement this feature. See prior art section below.
Not doing this
Not doing this means that people will continue to use the brittle workarounds presented in the motivation section.
Prior art
Most compilers provide a feature with...
RFC 2386
RFC
2018-04-03
~6 min read
rust-lang.github.io
...without a matching link reference definition
2. whose link label, after stripping leading and trailing back ticks, is a valid Rust path
it will add a link reference definition for this link label pointing to the Rust path.
Collapsed reference links ([link label][]) are handled analogously.
(This was one of...
RFC 1946
RFC
2017-03-06
~13 min read
rust-lang.github.io
...Note that the Rust style guide will generally match the latest version of the Rust style; the style team does not plan to maintain multiple branches of the style guide for different editions, in part because formatting for new constructs will apply to any edition supporting those constructs.
This RFC...
RFC 3309
RFC
2022-08-25
~6 min read
rust-lang.github.io
...Cargo runs the equivalent of cargo rustdoc --examples (source).
• Specifically, when constructing the BuildContext, Cargo will now recursively invoke rustdoc on all files matching the --examples filter.
• Each invocation includes a flag --scrape-examples <output path> which directs rustdoc to output to a file at the specific location.
3. An...
RFC 3123
RFC
2021-05-09
~6 min read
rust-lang.github.io
...let values = vec![1, 2, 3, 4, 5];
{
let result = match IntoIterator::into_iter(values) {
mut iter => loop {
let next;
match iter.next() {
Some(val) => next = val,
None => break,
};
let x = next;
let () = { println!("{}", x); };
},
};
result
}
• for x in &iter uses impl IntoIterator for &T
• for x in &mut iter...
RFC 2996
RFC
2020-09-29
~21 min read
rust-lang.github.io
...T) -> Cow<'static, T, B> {
Owned(owned)
}
pub fn is_owned(&self) -> bool {
match *self {
Owned(_) => true,
Shared(_) => false
}
}
pub fn to_owned_mut(&mut self) -> &mut T {
match *self {
Shared(shared) => {
*self = Owned(FromBorrow::from_borrow(shared));
self.to_owned_mut()
}
Owned(ref mut owned) => owned
}
}
pub fn into...
RFC 235
RFC
2014-10-29
~45 min read
rust-lang.github.io
...PrivStruct) { ... }
}
Implementations
To some extent, implementations are prevented from exposing private types because their types must match the trait. However, that is not true with generics.
pub trait PubTrait<T> {
fn method(t: T);
}
struct PubStruct { ... }
struct PrivStruct { ... }
impl PubTrait<PrivStruct> for PubStruct {
// ^~~~~~~~~~ Error: Private type referenced from impl of...
RFC 136
RFC
2014-06-24
~6 min read
rust-lang.github.io
...without using unsafe:
impl<T, E> Foo for Result<T, E> {
fn foo_computation(&self) -> u8 {
// Let's assume the implementation does something interesting..
match *self {
Ok(_) => 0,
Err(_) => 1,
}
}
}
Since Result<T, E> did not use unsafe in its implementation of Foo, you can still use my_result.foo...
RFC 2316
RFC
2018-01-30
~6 min read
rust-lang.github.io
...To remedy that, we could change the name of the trait to something like Closure(A) -> B (naturally the other traits would be renamed to match).
Then there are a large number of permutations and options that were largely rejected:
Only offer by-value closures. We tried this and found...
RFC 114
RFC
2014-07-29
~14 min read
rust-lang.github.io
...Association with exception handling - Both a pro and con
I think that there is a belief – one that I have shared from time to time – that it is not helpful to use familiar keywords unless the semantics are a perfect match, the concern being that they will setup an intuition...
RFC 2388
RFC
2018-04-04
~23 min read
rust-lang.github.io
...fn outer() {
unsafe {
#[no_mangle]
fn write() {}
}
}
This matches the fact that expression-level unsafety is not inherited for items declared inside other items.
Drawbacks
I think if we had thought of this around Rust 1.0, then this would be rather uncontroversial. As things stand now, this proposal will...
RFC 3325
RFC
2022-10-11
~6 min read
rust-lang.github.io
...this is a limitation of the runner image and I've filed an issue to have it fixed.
• Various debug info tests
• tests/debuginfo/step-into-match.rs: Stepping out of functions behaves differently.
• tests/debuginfo/type-names.rs: Arm64 Windows cdb doesn't support JavaScript extensions. I've filed...
RFC 3817
RFC
2025-05-22
~6 min read
rust-lang.github.io
...However, I believe that if we wish to support proper FFI with C, then a standard type that matches calling conventions with C complex numbers is an important feature of the language. Hence, I do not recommend this idea.
• Use a polar layout: Polar complex numbers are undoubtedly a more...
RFC 3892
RFC
2025-12-02
~6 min read
rust-lang.github.io
...In other cases we need to link to a library located at some specific path or not matching the default naming conventions. This RFC introduces modifier verbatim to pass such libraries to the linker.
This RFC also reformulates the static-nobundle linking kind as a modifier bundle thus providing an...
RFC 2951
RFC
2020-06-12
~6 min read
rust-lang.github.io
...Vec<String>,
}
impl OneOf {
pub fn matches(self) -> bool {
// Ok! destructure self
self.of.into_iter().any(|s| s == self.text)
}
pub fn filter(&mut self) {
// Ok! mutate and inspect self
self.of.retain(|s| s != &self.text)
}
}
Rust will prevent dangerous double usage:
struct FirstDuplicated(Vec<String>)
impl FirstDuplicated...
RFC 2229
RFC
2017-11-28
~7 min read
rust-lang.github.io
...Rebuilding the standard library to match the user's profile
2. Rebuilding the standard library with ABI-modifying flags
3. Building the standard library for tier three targets
Proposals to solve these problems come broadly under the umbrella of "build-std" and date back over 10 years ago, though no...
RFC 3873
RFC
2025-06-05
~39 min read