rust/library/alloc/src
Trevor Gross c8b2f7e458
Rollup merge of #131120 - tgross35:stabilize-const_option, r=RalfJung
Stabilize `const_option`

This makes the following API stable in const contexts:

```rust
impl<T> Option<T> {
    pub const fn as_mut(&mut self) -> Option<&mut T>;
    pub const fn expect(self, msg: &str) -> T;
    pub const fn unwrap(self) -> T;
    pub const unsafe fn unwrap_unchecked(self) -> T;
    pub const fn take(&mut self) -> Option<T>;
    pub const fn replace(&mut self, value: T) -> Option<T>;
}

impl<T> Option<&T> {
    pub const fn copied(self) -> Option<T>
    where T: Copy;
}

impl<T> Option<&mut T> {
    pub const fn copied(self) -> Option<T>
    where T: Copy;
}

impl<T, E> Option<Result<T, E>> {
    pub const fn transpose(self) -> Result<Option<T>, E>
}

impl<T> Option<Option<T>> {
    pub const fn flatten(self) -> Option<T>;
}
```

The following functions make use of the unstable `const_precise_live_drops` feature:

- `expect`
- `unwrap`
- `unwrap_unchecked`
- `transpose`
- `flatten`

Fixes: <https://github.com/rust-lang/rust/issues/67441>
2024-10-12 21:38:35 -05:00
..
alloc Reformat use declarations. 2024-07-29 08:26:52 +10:00
boxed Use &raw in the standard library 2024-09-25 17:03:20 -07:00
collections Avoid emptiness check in PeekMut::pop 2024-10-03 22:15:52 +08:00
ffi Mark some more types as having insignificant dtor 2024-09-27 11:59:39 -04:00
raw_vec Polymorphize RawVec 2024-08-09 20:06:26 -04:00
rc Add str.as_str() for easy dereferencing of Box<str> 2024-09-19 16:25:56 +01:00
sync Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
testing Reformat use declarations. 2024-07-29 08:26:52 +10:00
vec Rollup merge of #128399 - mammothbane:master, r=Amanieu,tgross35 2024-10-07 15:37:06 +11:00
alloc.rs read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroed 2024-09-17 22:26:21 -04:00
borrow.rs remove const_cow_is_borrowed feature gate 2024-10-12 19:48:28 +02:00
boxed.rs Mark some more smart pointers as insignificant 2024-09-27 11:59:39 -04:00
fmt.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
lib.miri.rs add 'x.py miri', and make it work for 'library/{core,alloc,std}' 2024-04-03 20:27:20 +02:00
lib.rs Rollup merge of #131120 - tgross35:stabilize-const_option, r=RalfJung 2024-10-12 21:38:35 -05:00
macros.rs Mark format! with must_use hint 2024-07-06 14:24:20 +02:00
raw_vec.rs liballoc: introduce String, Vec const-slicing 2024-10-06 19:58:35 -04:00
rc.rs Use &raw in the standard library 2024-09-25 17:03:20 -07:00
slice.rs Port sort-research-rs test suite Rust stdlib tests 2024-09-30 15:05:30 +02:00
str.rs Improve autovectorization of to_lowercase / to_uppercase functions 2024-09-23 11:31:29 +02:00
string.rs Rollup merge of #128399 - mammothbane:master, r=Amanieu,tgross35 2024-10-07 15:37:06 +11:00
sync.rs Mark some more smart pointers as insignificant 2024-09-27 11:59:39 -04:00
task.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
tests.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00