replace version placeholder
This commit is contained in:
@@ -64,7 +64,7 @@ union Data<T, F> {
|
||||
/// println!("{}", *data.number);
|
||||
/// }
|
||||
/// ```
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
pub struct LazyLock<T, F = fn() -> T> {
|
||||
once: Once,
|
||||
data: UnsafeCell<Data<T, F>>,
|
||||
@@ -85,8 +85,8 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
|
||||
/// assert_eq!(&*lazy, "HELLO, WORLD!");
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
#[rustc_const_stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
pub const fn new(f: F) -> LazyLock<T, F> {
|
||||
LazyLock { once: Once::new(), data: UnsafeCell::new(Data { f: ManuallyDrop::new(f) }) }
|
||||
}
|
||||
@@ -152,7 +152,7 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
|
||||
/// assert_eq!(&*lazy, &92);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
pub fn force(this: &LazyLock<T, F>) -> &T {
|
||||
this.once.call_once(|| {
|
||||
// SAFETY: `call_once` only runs this closure once, ever.
|
||||
@@ -188,7 +188,7 @@ impl<T, F> LazyLock<T, F> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
impl<T, F> Drop for LazyLock<T, F> {
|
||||
fn drop(&mut self) {
|
||||
match self.once.state() {
|
||||
@@ -201,7 +201,7 @@ impl<T, F> Drop for LazyLock<T, F> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
impl<T, F: FnOnce() -> T> Deref for LazyLock<T, F> {
|
||||
type Target = T;
|
||||
|
||||
@@ -216,7 +216,7 @@ impl<T, F: FnOnce() -> T> Deref for LazyLock<T, F> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
impl<T: Default> Default for LazyLock<T> {
|
||||
/// Creates a new lazy value using `Default` as the initializing function.
|
||||
#[inline]
|
||||
@@ -225,7 +225,7 @@ impl<T: Default> Default for LazyLock<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
impl<T: fmt::Debug, F> fmt::Debug for LazyLock<T, F> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut d = f.debug_tuple("LazyLock");
|
||||
@@ -239,13 +239,13 @@ impl<T: fmt::Debug, F> fmt::Debug for LazyLock<T, F> {
|
||||
|
||||
// We never create a `&F` from a `&LazyLock<T, F>` so it is fine
|
||||
// to not impl `Sync` for `F`.
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
unsafe impl<T: Sync + Send, F: Send> Sync for LazyLock<T, F> {}
|
||||
// auto-derived `Send` impl is OK.
|
||||
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
impl<T: RefUnwindSafe + UnwindSafe, F: UnwindSafe> RefUnwindSafe for LazyLock<T, F> {}
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
impl<T: UnwindSafe, F: UnwindSafe> UnwindSafe for LazyLock<T, F> {}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -182,7 +182,7 @@ pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
#[stable(feature = "lazy_cell", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[stable(feature = "lazy_cell", since = "1.80.0")]
|
||||
pub use self::lazy_lock::LazyLock;
|
||||
#[stable(feature = "once_cell", since = "1.70.0")]
|
||||
pub use self::once_lock::OnceLock;
|
||||
|
||||
Reference in New Issue
Block a user