X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=library%2Fstd%2Fsrc%2Fsync%2Flazy_lock.rs;h=4a15305301d69714badce18702986f90be660e18;hb=ce85c98575e3016cf2007d90a85be321e592aa96;hp=bf5a716fa03898dd344a31c46a89a2d643dcf226;hpb=bbdca4c28fd9b57212cb3316ff4ffb1529affcbe;p=rust.git diff --git a/library/std/src/sync/lazy_lock.rs b/library/std/src/sync/lazy_lock.rs index bf5a716fa03..4a15305301d 100644 --- a/library/std/src/sync/lazy_lock.rs +++ b/library/std/src/sync/lazy_lock.rs @@ -49,6 +49,7 @@ pub struct LazyLock T> { impl T> LazyLock { /// Creates a new lazy value with the given initializing /// function. + #[inline] #[unstable(feature = "once_cell", issue = "74465")] pub const fn new(f: F) -> LazyLock { LazyLock { cell: OnceLock::new(), init: Cell::new(Some(f)) } @@ -70,6 +71,7 @@ pub const fn new(f: F) -> LazyLock { /// assert_eq!(LazyLock::force(&lazy), &92); /// assert_eq!(&*lazy, &92); /// ``` + #[inline] #[unstable(feature = "once_cell", issue = "74465")] pub fn force(this: &LazyLock) -> &T { this.cell.get_or_init(|| match this.init.take() { @@ -82,6 +84,8 @@ pub fn force(this: &LazyLock) -> &T { #[unstable(feature = "once_cell", issue = "74465")] impl T> Deref for LazyLock { type Target = T; + + #[inline] fn deref(&self) -> &T { LazyLock::force(self) } @@ -90,6 +94,7 @@ fn deref(&self) -> &T { #[unstable(feature = "once_cell", issue = "74465")] impl Default for LazyLock { /// Creates a new lazy value using `Default` as the initializing function. + #[inline] fn default() -> LazyLock { LazyLock::new(T::default) }