]> git.lizzy.rs Git - rust.git/blobdiff - library/core/src/cell/lazy.rs
Auto merge of #105651 - tgross35:once-cell-inline, r=m-ou-se
[rust.git] / library / core / src / cell / lazy.rs
index 19f80daef1d3bc99c162d5ad00d396c6d181b4ce..65d12c25c51a48a13c7ddb7de65e233447764827 100644 (file)
@@ -51,6 +51,7 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
     ///
     /// assert_eq!(&*lazy, "HELLO, WORLD!");
     /// ```
+    #[inline]
     #[unstable(feature = "once_cell", issue = "74465")]
     pub const fn new(init: F) -> LazyCell<T, F> {
         LazyCell { cell: OnceCell::new(), init: Cell::new(Some(init)) }
@@ -73,6 +74,7 @@ pub const fn new(init: F) -> LazyCell<T, F> {
     /// assert_eq!(LazyCell::force(&lazy), &92);
     /// assert_eq!(&*lazy, &92);
     /// ```
+    #[inline]
     #[unstable(feature = "once_cell", issue = "74465")]
     pub fn force(this: &LazyCell<T, F>) -> &T {
         this.cell.get_or_init(|| match this.init.take() {
@@ -85,6 +87,7 @@ pub fn force(this: &LazyCell<T, F>) -> &T {
 #[unstable(feature = "once_cell", issue = "74465")]
 impl<T, F: FnOnce() -> T> Deref for LazyCell<T, F> {
     type Target = T;
+    #[inline]
     fn deref(&self) -> &T {
         LazyCell::force(self)
     }
@@ -93,6 +96,7 @@ fn deref(&self) -> &T {
 #[unstable(feature = "once_cell", issue = "74465")]
 impl<T: Default> Default for LazyCell<T> {
     /// Creates a new lazy value using `Default` as the initializing function.
+    #[inline]
     fn default() -> LazyCell<T> {
         LazyCell::new(T::default)
     }