Skip to content

Commit

Permalink
Implement Default for OnceCell (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-Bertholet authored Nov 8, 2023
1 parent 33d64af commit 902e8f9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/once_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,14 @@ impl<T> Drop for OnceCell<T> {
}
}

impl<T> Default for OnceCell<T> {
// Calls `OnceCell::new`.
#[inline]
fn default() -> Self {
Self::new()
}
}

/// Either return the result of a future now, or panic.
#[cfg(all(feature = "std", not(target_family = "wasm")))]
fn now_or_never<T>(f: impl Future<Output = T>) -> T {
Expand Down

0 comments on commit 902e8f9

Please sign in to comment.