about summary refs log tree commit diff
path: root/library/core/src/time.rs
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2024-10-01 17:11:48 -0400
committerTrevor Gross <tmgross@umich.edu>2024-10-12 17:07:13 -0400
commit19f6c17df486c5f70c1000ecada39c62b9c93550 (patch)
tree326ea966597781d18a42c85e1851eed464cba193 /library/core/src/time.rs
parent6b9676b45431a1e531b9c5f7bd289fc36a312749 (diff)
downloadrust-19f6c17df486c5f70c1000ecada39c62b9c93550.tar.gz
rust-19f6c17df486c5f70c1000ecada39c62b9c93550.zip
Stabilize `const_option`
This makes the following API stable in const contexts:

    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>
Diffstat (limited to 'library/core/src/time.rs')
-rw-r--r--library/core/src/time.rs1
1 files changed, 0 insertions, 1 deletions
diff --git a/library/core/src/time.rs b/library/core/src/time.rs
index a997874dd9c..f7ea7e06e9c 100644
--- a/library/core/src/time.rs
+++ b/library/core/src/time.rs
@@ -626,7 +626,6 @@ impl Duration {
     /// ```
     #[stable(feature = "duration_abs_diff", since = "1.81.0")]
     #[rustc_const_stable(feature = "duration_abs_diff", since = "1.81.0")]
-    #[rustc_allow_const_fn_unstable(const_option)]
     #[must_use = "this returns the result of the operation, \
                   without modifying the original"]
     #[inline]