about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-08-22 08:17:22 +0200
committerGitHub <noreply@github.com>2024-08-22 08:17:22 +0200
commit28d4b8248e319cddb04f9c7ec0f8bdcbd642bb3f (patch)
tree85a44ff461540a69f4167e70cd21094815db1a9b
parentae58bbfbce40d81efa6e668b22066859003291ce (diff)
parent81c00dde2b15120fd1e492909957feb720e33d0a (diff)
downloadrust-28d4b8248e319cddb04f9c7ec0f8bdcbd642bb3f.tar.gz
rust-28d4b8248e319cddb04f9c7ec0f8bdcbd642bb3f.zip
Rollup merge of #129382 - tgross35:once-cell-const-into-inner, r=Noratrieb
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
-rw-r--r--library/core/src/cell/once.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/core/src/cell/once.rs b/library/core/src/cell/once.rs
index 097fa86c938..87df8a4e272 100644
--- a/library/core/src/cell/once.rs
+++ b/library/core/src/cell/once.rs
@@ -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()