Rollup merge of #131712 - tgross35:const-lazy_cell_into_inner, r=joboet

Mark the unstable LazyCell::into_inner const

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: https://github.com/rust-lang/rust/issues/125623
This commit is contained in:
Urgau 2024-10-16 12:03:41 +02:00 committed by GitHub
commit f7af3aa7dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,7 +79,7 @@ pub const fn new(f: F) -> 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),
@ -306,6 +306,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cold]
#[inline(never)]
fn panic_poisoned() -> ! {
const fn panic_poisoned() -> ! {
panic!("LazyCell instance has previously been poisoned")
}