diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2024-10-12 21:38:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-12 21:38:35 -0500 |
| commit | ea48cf362c3ec0e94b1c7bfee1c8605d978268dd (patch) | |
| tree | c92492ded8740147e16aaf3b5132a747d180e921 | |
| parent | b1c468422a6f1d3cae8f068dcdd1dac4e47dbfac (diff) | |
| parent | 3c43a60d0652a1e8b62bf11d559a02d5cd20119d (diff) | |
| download | rust-ea48cf362c3ec0e94b1c7bfee1c8605d978268dd.tar.gz rust-ea48cf362c3ec0e94b1c7bfee1c8605d978268dd.zip | |
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>
| -rw-r--r-- | tests/ui/doc/doc-fixable.fixed | 2 | ||||
| -rw-r--r-- | tests/ui/doc/doc-fixable.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/tests/ui/doc/doc-fixable.fixed b/tests/ui/doc/doc-fixable.fixed index edfffe8fcfe..355f2bc7736 100644 --- a/tests/ui/doc/doc-fixable.fixed +++ b/tests/ui/doc/doc-fixable.fixed @@ -3,7 +3,7 @@ #![allow(dead_code, incomplete_features)] #![warn(clippy::doc_markdown)] -#![feature(custom_inner_attributes, generic_const_exprs, const_option)] +#![feature(custom_inner_attributes, generic_const_exprs)] #![rustfmt::skip] /// The `foo_bar` function does _nothing_. See also `foo::bar`. (note the dot there) diff --git a/tests/ui/doc/doc-fixable.rs b/tests/ui/doc/doc-fixable.rs index 3c0f6913e32..9ced2677622 100644 --- a/tests/ui/doc/doc-fixable.rs +++ b/tests/ui/doc/doc-fixable.rs @@ -3,7 +3,7 @@ #![allow(dead_code, incomplete_features)] #![warn(clippy::doc_markdown)] -#![feature(custom_inner_attributes, generic_const_exprs, const_option)] +#![feature(custom_inner_attributes, generic_const_exprs)] #![rustfmt::skip] /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) |
