Skip to content

Commit

Permalink
Mark LazyCell::into_inner unstably const
Browse files Browse the repository at this point in the history
Other cell `into_inner` functions are const and there shouldn't be any
problem here. Make the unstable `LazyCell::into_inner` const under the
same gate as its stability (`lazy_cell_into_inner`).

Tracking issue: #125623
  • Loading branch information
tgross35 committed Oct 14, 2024
1 parent 9322d18 commit 373142a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/cell/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
/// assert_eq!(LazyCell::into_inner(lazy).ok(), Some("HELLO, WORLD!".to_string()));
/// ```
#[unstable(feature = "lazy_cell_into_inner", issue = "125623")]
pub fn into_inner(this: Self) -> Result<T, F> {
pub const fn into_inner(this: Self) -> Result<T, F> {
match this.state.into_inner() {
State::Init(data) => Ok(data),
State::Uninit(f) => Err(f),
Expand Down Expand Up @@ -306,6 +306,6 @@ impl<T: fmt::Debug, F> fmt::Debug for LazyCell<T, F> {

#[cold]
#[inline(never)]
fn panic_poisoned() -> ! {
const fn panic_poisoned() -> ! {
panic!("LazyCell instance has previously been poisoned")
}

0 comments on commit 373142a

Please sign in to comment.