rust-lang.github.io
Summary
Make the count parameter of SliceExt::splitn, StrExt::splitn and corresponding reverse variants mean the maximum number of items returned, instead of the maximum number of times to match the separator.
Motivation
The majority of other languages (see examples below) treat the count parameter as the maximum number of...
RFC 979
RFC
2015-03-15
~2 min read
rust-lang.github.io
...Crates scope
The patterns will be evaluated during each API call, and if no match is found the request will be denied. Because it's evaluated every time, a crates scope will allow interacting with matching crates published after token creation.
The check for the crates scope is separate from...
RFC 2947
RFC
2022-11-08
~6 min read
rust-lang.github.io
...Making temporary lifetime extension consistent between block expressions and if/else blocks and match arms. This has already been implemented and approved: https://github.com/rust-lang/rust/pull/121346
•
Dropping temporaries in a match scrutinee before the arms are evaluated, rather than after, to prevent deadlocks. This has been...
RFC 3606
RFC
2024-04-02
~5 min read
rust-lang.github.io
...For instance, could we have pub macro_helper_attr! skip in the standard library, namespaced under core::derives or similar? Could we let macros parse that in a way that matches it in a namespaced fashion, so that:
• If you write #[core::derives::skip], the macro matches it
• If you...
RFC 3698
RFC
2024-09-20
~9 min read
rust-lang.github.io
...in match patterns is "inclusive". To avoid confusion, we propose to change the match notation to ... to reflect the distinction. The reason to change the notation, rather than the interpretation, is that the exclusive (respectively inclusive) interpretation is the right default for slicing (respectively matching).
Rationale for the notation
The...
RFC 198
RFC
2014-09-11
~6 min read
rust-lang.github.io
...Inner attributes
Inner attributes can be placed at the top of blocks (and other structure incorporating a block) and apply to that block.
{
#![attr11]
foo()
}
match bar {
#![attr12]
_ => {}
}
// are the same as
#[attr11]
{
foo()
}
#[attr12]
match bar {
_ => {}
}
if
Attributes would be disallowed on if for now, because the interaction with...
RFC 16
RFC
2014-03-20
~4 min read
rust-lang.github.io
...Rc<[Wrap]> = Rc::from(arr.as_ref());
/// assert_eq!(rc.as_ref(), &arr); // The elements match.
/// assert_eq!(rc.len(), arr.len()); // The lengths match.
/// ```
///
/// Using the [`Into`][Into] trait:
///
/// ```
/// #![feature(shared_from_slice)]
/// use std::rc::Rc;
///
/// #[derive(PartialEq, Clone, Debug)]
/// struct Wrap(u8);
///
/// let rc: Rc<[Wrap]> = arr...
RFC 1845
RFC
2017-01-05
~12 min read
github.com
...For instance, could we have `pub macro_helper_attr! skip` in the standard
library, namespaced under `core::derives` or similar? Could we let macros parse
that in a way that matches it in a namespaced fashion, so that:
- If you write `#[core::derives::skip]`, the macro matches it
- If you...
RFC 3698
RFC
2024-09-20
~9 min read
rust-lang.github.io
...We will also query the oauth_github table to see if the crates.io username and GitHub username match. If they do match, we will continue with adding this user as an owner. If they don't match, we will return an error containing information about the mismatch and asking...
RFC 3946
RFC
2026-04-07
~28 min read
rust-lang.github.io
...Unresolved questions
• The behavior specified here should match the behavior of MSVC at least. Does it match the behavior of other C/C++ compilers as well?
• Should it still be safe to borrow fields whose alignment is less than or equal to the specified packing or should all field borrows...
RFC 1399
RFC
2015-12-06
~3 min read
rust-lang.github.io
...F) -> U {
match self {
Some(t) => f(t),
None => Default::default(),
}
}
}
The following implementation would get added to core::result::Result:
impl<T, E> Result<T, E> {
pub fn map_or_default<U: Default, F: FnOnce(T) -> U>(self, f: F) -> U {
match self {
Ok(t) => f(t),
Err(e...
RFC 3148
RFC
2021-07-14
~1 min read
github.com
...When combined with `#[repr(C)]` the size alignment and layout of the struct
should match the equivalent struct in C.
`#[repr(packed)]` and `#[repr(packed = "1")]` should have identical behavior.
Because this lowers the effective alignment of fields in the same way that
`#[repr(packed)]` does (which caused [issue #27060...
RFC 1399
RFC
2015-12-06
~3 min read
rust-lang.github.io
...let x = (0, 2);
match x {
(0, ref y) | (ref y, 0) => { /* use y */}
_ => ()
}
Alternatively, split the pattern:
let x = (0, 2);
match x {
(y, 0) => { /* use y */ }
(0, ref y) => { /* use y */}
_ => ()
}
"##,
Drawbacks
This will make contributing slightly more complex, as there are rules to follow, whereas right now...
RFC 1567
RFC
2016-01-04
~3 min read
rust-lang.github.io
...A filter option evaluates to true if the corresponding generic parameter in the trait definition matches the specified type. The provided message/note/label options are only emitted if the filter operation evaluates to true.
The any and all options allow to combine multiple filter options. The any option matches...
RFC 3368
RFC
2023-01-06
~9 min read
rust-lang.github.io
...Features:
+ perf Enables all performance related features
+ perf-dfa Enables the use of a lazy DFA for matching
+ perf-inline Enables the use of aggressive inlining inside
match routines
+ perf-literal Enables the use of literal optimizations for
speeding up matches
+ std When enabled, this will cause regex to use...
RFC 3416
RFC
2023-04-14
~3 min read
rust-lang.github.io
...And requiring matching on every use of the type is less ergonomic. For example, the clamp RFC would naturally use a RangeInclusive parameter, but because it still needs to assert!(start <= end) in the NonEmpty arm, the noise of the Empty vs NonEmpty match provides it no value.
• a...b...
RFC 1192
RFC
2015-07-07
~5 min read
github.com
...And requiring matching on every
use of the type is less ergonomic. For example, the clamp RFC would
naturally use a `RangeInclusive` parameter, but because it still needs
to `assert!(start <= end)` in the `NonEmpty` arm, the noise of the `Empty`
vs `NonEmpty` match provides it no value.
- `a...b...
RFC 1192
RFC
2015-07-07
~5 min read
rust-lang.github.io
...As such, the lang team will need to approve the high-level answer.
•
Do match guards have semantic meaning?
Match guards are inserted by the compiler around match statements to ensure that if guards cannot change the value being matched on. Whether match guards should exist at all primarily affects...
RFC 3346
RFC
2022-11-07
~8 min read
rust-lang.github.io
...Usually, you'll want to copy this value from a corresponding -fpatchable-function-entry= being passed to the C compiler in your project - total_nops will match the first parameter used by your C compiler, and the optional offset parameter passed to the C compiler will match prefix_nops.
To...
RFC 3543
RFC
2023-12-12
~11 min read
rust-lang.github.io
...Motivation
Right now accessing fields of tuples and tuple structs is incredibly painful—one must rely on pattern-matching alone to extract values. This became such a problem that twelve traits were created in the standard library (core::tuple::Tuple*) to make tuple value accesses easier, adding .valN(), .refN(), and...
RFC 184
RFC
2014-07-24
~1 min read