mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Add const_cell_into_inner
to OnceCell
`Cell` and `RefCell` have their `into_inner` methods const unstable. `OnceCell` has the same logic, so add it under the same gate. Tracking issue: https://github.com/rust-lang/rust/issues/78729
This commit is contained in:
parent
6b678c57b6
commit
81c00dde2b
@ -309,7 +309,8 @@ impl<T> OnceCell<T> {
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "once_cell", since = "1.70.0")]
|
||||
pub fn into_inner(self) -> Option<T> {
|
||||
#[rustc_const_unstable(feature = "const_cell_into_inner", issue = "78729")]
|
||||
pub const fn into_inner(self) -> Option<T> {
|
||||
// Because `into_inner` takes `self` by value, the compiler statically verifies
|
||||
// that it is not currently borrowed. So it is safe to move out `Option<T>`.
|
||||
self.inner.into_inner()
|
||||
|
Loading…
Reference in New Issue
Block a user