rust-lang.github.io
...Option<T>) -> T {
match input {
Some(t) => t,
None => panic!("nothing to see here, move along"),
}
}
fn main() {
println!("args[1] = {}", my_unwrap(args().nth(1)));
println!("args[2] = {}", my_unwrap(args().nth(2)));
println!("args[3] = {}", my_unwrap(args().nth(3)));
}
This trivial implementation, however, will only report the...
RFC 2091
RFC
2017-07-31
~30 min read
rust-lang.github.io
...fn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> io::Result<()> {
while buf.remaining() > 0 {
let prev_filled = buf.filled().len();
match self.read_buf(&mut buf) {
Ok(()) => {}
Err(e) if e.kind() == io::ErrorKind::Interrupted => continue,
Err(e) => return Err(e),
}
if buf.filled().len() == prev_filled {
return Err...
RFC 2930
RFC
2020-10-28
~18 min read
rust-lang.github.io
...Otherwise, we expand that macro by parsing the arguments, pattern matching, and doing hygienic expansion. We then parse the generated code in the same way as we parsed the original program. We add new names to the binding table, and expand any new macro uses.
If we add names for...
RFC 1560
RFC
2016-02-09
~18 min read
rust-lang.github.io
...This is normally
+ // done for end-product dylibs, not intermediate products.
+ config::CrateTypeDylib if !sess.opts.cg.prefer_dynamic => {
+ match attempt_static(sess) {
+ Some(v) => return v,
+ None => {}
+ }
+ }
+
// Everything else falls through below
config::CrateTypeExecutable | config::CrateTypeDylib => {},
}
Drawbacks
None currently, but the next section of alternatives lists a few other...
RFC 404
RFC
2014-11-01
~4 min read
rust-lang.github.io
...cargo team
| Goal | Owner | Notes | | --- | --- | --- | | Approve RFC | | | | ↳ Yank crates with a reason | 二手掉包工程师 | | | Design meeting | | | | ↳ User-wide caching | Help wanted | | | Discussion and moral support | | | | ↳ Explore sandboxed build scripts | Weihang Lo | | | ↳ Extend pubgrub to match cargo's dependency resolution | Jacob Finkelman | | | ↳ Begin resolving cargo-semver-checks blockers for merging into cargo...
RFC 3672
RFC
2024-07-09
~15 min read
github.com
...However, this introduces an unnecessary level of indirection that does not
match the developer's intuition and mental model as well as it could. In
particular, given the ability to write bounds on a type variable as `T: Bounds`,
it makes sense to permit writing bounds on an associated type...
RFC 2289
RFC
2018-01-13
~5 min read
rust-lang.github.io
...Motivation
Looking at the amount of cstr!() invocations just on GitHub (about 3.2k files with matches) it seems like C string literals are a widely used feature. Implementing cstr!() as a macro_rules or proc_macro requires non-trivial code to get it completely right (e.g. refusing embedded...
RFC 3348
RFC
2022-11-15
~4 min read
rust-lang.github.io
...For example, we could use @, as an analogy with its use as a binding operator in match expressions:
mod new_code {
use a::b::c::d::www;
use a::b::c::e::xxx;
use a::b::yummy @ yyy;
use a::b::c::g::zzz;
}
(I do not object to path...
RFC 169
RFC
2014-07-16
~5 min read
rust-lang.github.io
...However, when it is feasible to do so, debugging output should match Rust syntax; doing so makes it easier to copy debug output into unit tests, for example.
User-facing: fmt::Display
The fmt::Display trait is intended for user-facing output. It should:
• Be implemented for scalars, strings, and...
RFC 565
RFC
2015-01-08
~5 min read
github.com
...When no version matches
If no version of a dependency satisfies both the version requirement and the minimum publish age, the resolve will error, similar to when all matching versions are yanked:
$ cargo update
error: failed to select a version for the requirement `some-package = "^1.3"`
version 1.3...
RFC 3923
RFC
2026-02-23
~17 min read
rust-lang.github.io
...When no version matches
If no version of a dependency satisfies both the version requirement and the minimum publish age, the resolve will error, similar to when all matching versions are yanked:
$ cargo update
error: failed to select a version for the requirement `some-package = "^1.3"`
version 1.3...
RFC 3923
RFC
2026-02-23
~17 min read
rust-lang.github.io
...IntoOwned more closely matches the semantics we actually want for our entry keys, because we really don't care about preserving them after the conversion. This would allow us to dispatch to either a no-op or a full clone as necessary. This trait would also be appropriate for the...
RFC 509
RFC
2014-12-18
~11 min read
rust-lang.github.io
...A policy on this needs to balance
• Matching the expectation of a reproducible Rust experience
• Users wanting the latest experience, in general
• Boilerplate runs counter to experimentation and prototyping, particularly in the "no dependencies" case
• A cargo new --script (flag TBD) could help reduce writing of boilerplate.
• There might not...
RFC 3502
RFC
2023-03-31
~38 min read
rust-lang.github.io
...This RFC proposes deprecating the compare_and_swap function and replacing it with compare_exchange and compare_exchange_weak, which match the names of the equivalent C++11 functions (with the _strong suffix removed).
compare_exchange
A new method is instead added to atomic types:
fn compare_exchange(&self, current...
RFC 1443
RFC
2016-01-05
~4 min read
rust-lang.github.io
...one package requires touching all packages
• Has confusing cases where what you see locally (default-features = false) is not what happens
let default_features = match (workspace.default_features, package.default_features) {
(Some(false), Some(true)) => Some(true),
(Some(ws), _) => Some(ws),
(None, _) => Some(true),
};
"Layered" model
• Proposed behavior
• Allows package...
RFC 3945
RFC
2026-04-06
~5 min read
rust-lang.github.io
...Differences with YAML frontmatter include:
• Variable number of dashes (for escaping)
• Optional frontmatter
Besides characters, differences with commonmark code fences include:
• no indenting of the fenced code block
• open/close must be a matching pair, rather than the close having "the same or more"
Benefits:
• Visually/syntactically lightweight
• Users can...
RFC 3503
RFC
2023-09-26
~19 min read
github.com
...Option<T>) -> T {
match input {
Some(t) => t,
None => panic!("nothing to see here, move along"),
}
}
fn main() {
println!("args[1] = {}", my_unwrap(args().nth(1)));
println!("args[2] = {}", my_unwrap(args().nth(2)));
println!("args[3] = {}", my_unwrap(args().nth(3)));
}
```
This trivial implementation, however, will only report the...
RFC 2091
RFC
2017-07-31
~31 min read
rust-lang.github.io
...A version constraint is fundamentally an assertion from a library's author to its users that the library will work with any version of a dependency that matches its constraint. A wildcard constraint is claiming that the library will work with any version of the dependency that has ever been...
RFC 1241
RFC
2015-07-23
~5 min read
rust-lang.github.io
...Matching and coherence for the builtin types Copy and Sized
In general, determining whether a type implements a builtin trait can follow the existing trait matching algorithm, but it will have to be somewhat specialized. The problem is that we are somewhat limited in the kinds of impls that we...
RFC 19
RFC
2014-09-18
~19 min read
rust-lang.github.io
...Because the calling convention of a naked function is not guaranteed to match any calling convention the compiler is compatible with, calls to naked functions from within Rust code are forbidden unless the function is also declared with a well-defined ABI.
Defining a naked function with the default (Rust...
RFC 1201
RFC
2015-07-10
~5 min read