Skip to content

Commit 902e8f9

Browse files
Implement Default for OnceCell (#63)
1 parent 33d64af commit 902e8f9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/once_cell.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,14 @@ impl<T> Drop for OnceCell<T> {
763763
}
764764
}
765765

766+
impl<T> Default for OnceCell<T> {
767+
// Calls `OnceCell::new`.
768+
#[inline]
769+
fn default() -> Self {
770+
Self::new()
771+
}
772+
}
773+
766774
/// Either return the result of a future now, or panic.
767775
#[cfg(all(feature = "std", not(target_family = "wasm")))]
768776
fn now_or_never<T>(f: impl Future<Output = T>) -> T {

0 commit comments

Comments
 (0)