diff options
| author | Trevor Gross <tmgross@umich.edu> | 2024-08-21 17:22:08 -0500 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2024-08-21 17:36:05 -0500 |
| commit | 81c00dde2b15120fd1e492909957feb720e33d0a (patch) | |
| tree | 33821f042bfc935a28e4f80beee3f9c0e58e565f | |
| parent | 6b678c57b63b3062fb97130b3617b82657f59c80 (diff) | |
| download | rust-81c00dde2b15120fd1e492909957feb720e33d0a.tar.gz rust-81c00dde2b15120fd1e492909957feb720e33d0a.zip | |
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.rs | 3 |
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() |
