File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,19 @@ impl<T: UnwindSafe> UnwindSafe for SyncOnceCell<T> {}
8787
8888#[ unstable( feature = "once_cell" , issue = "74465" ) ]
8989impl < T > Default for SyncOnceCell < T > {
90+ /// Creates a new empty cell.
91+ ///
92+ /// # Example
93+ ///
94+ /// ```
95+ /// #![feature(once_cell)]
96+ ///
97+ /// use std::lazy::SyncOnceCell;
98+ ///
99+ /// fn main() {
100+ /// assert_eq!(SyncOnceCell::<()>::new(), SyncOnceCell::default());
101+ /// }
102+ /// ```
90103 fn default ( ) -> SyncOnceCell < T > {
91104 SyncOnceCell :: new ( )
92105 }
@@ -118,6 +131,23 @@ impl<T: Clone> Clone for SyncOnceCell<T> {
118131
119132#[ unstable( feature = "once_cell" , issue = "74465" ) ]
120133impl < T > From < T > for SyncOnceCell < T > {
134+ /// Create a new cell with its contents set to `value`.
135+ ///
136+ /// # Example
137+ ///
138+ /// ```
139+ /// #![feature(once_cell)]
140+ ///
141+ /// use std::lazy::SyncOnceCell;
142+ ///
143+ /// # fn main() -> Result<(), i32> {
144+ /// let a = SyncOnceCell::from(3);
145+ /// let b = SyncOnceCell::new();
146+ /// b.set(3)?;
147+ /// assert_eq!(a, b);
148+ /// Ok(())
149+ /// # }
150+ /// ```
121151 fn from ( value : T ) -> Self {
122152 let cell = Self :: new ( ) ;
123153 match cell. set ( value) {
You can’t perform that action at this time.
0 commit comments