Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize const_option #131120

Merged
merged 1 commit into from
Oct 13, 2024
Merged

Stabilize const_option #131120

merged 1 commit into from
Oct 13, 2024

Commits on Oct 12, 2024

  1. 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: <rust-lang#67441>
    tgross35 committed Oct 12, 2024
    Configuration menu
    Copy the full SHA
    19f6c17 View commit details
    Browse the repository at this point in the history