Skip to content

Commit

Permalink
Add const_cell_into_inner to OnceCell
Browse files Browse the repository at this point in the history
`Cell` and `RefCell` have their `into_inner` methods const unstable.
`OnceCell` has the same logic, so add it under the same gate.

Tracking issue: rust-lang#78729
  • Loading branch information
tgross35 committed Aug 21, 2024
1 parent d37ebfe commit 863123b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/cell/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 863123b

Please sign in to comment.