From 81c00dde2b15120fd1e492909957feb720e33d0a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 21 Aug 2024 17:22:08 -0500 Subject: [PATCH] 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 --- library/core/src/cell/once.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/cell/once.rs b/library/core/src/cell/once.rs index 097fa86c93814..87df8a4e272e8 100644 --- a/library/core/src/cell/once.rs +++ b/library/core/src/cell/once.rs @@ -309,7 +309,8 @@ impl OnceCell { /// ``` #[inline] #[stable(feature = "once_cell", since = "1.70.0")] - pub fn into_inner(self) -> Option { + #[rustc_const_unstable(feature = "const_cell_into_inner", issue = "78729")] + pub const fn into_inner(self) -> Option { // 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`. self.inner.into_inner()