Skip to content

Commit cfc04cf

Browse files
committed
Add const default for OnceCell and OnceLock
Signed-off-by: tison <[email protected]>
1 parent d5525a7 commit cfc04cf

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

library/core/src/cell/once.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ impl<T> OnceCell<T> {
353353
}
354354

355355
#[stable(feature = "once_cell", since = "1.70.0")]
356-
impl<T> Default for OnceCell<T> {
356+
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
357+
impl<T> const Default for OnceCell<T> {
357358
#[inline]
358359
fn default() -> Self {
359360
Self::new()

library/std/src/sync/once_lock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,8 @@ impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T> {}
582582
impl<T: UnwindSafe> UnwindSafe for OnceLock<T> {}
583583

584584
#[stable(feature = "once_cell", since = "1.70.0")]
585-
impl<T> Default for OnceLock<T> {
585+
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
586+
impl<T> const Default for OnceLock<T> {
586587
/// Creates a new uninitialized cell.
587588
///
588589
/// # Example

0 commit comments

Comments
 (0)