File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ impl<T> OnceCell<T> {
165165 }
166166
167167 #[ inline]
168+ #[ stable( feature = "once_cell" , since = "1.70.0" ) ]
168169 pub fn get_mut_or_init < F > ( & mut self , f : F ) -> & mut T
169170 where
170171 F : FnOnce ( ) -> T ,
@@ -210,10 +211,10 @@ impl<T> OnceCell<T> {
210211 if let Some ( val) = self . get ( ) {
211212 return Ok ( val) ;
212213 }
213- self . try_init ( f) ?;
214- Ok ( self . get ( ) . unwrap ( ) )
214+ self . try_init ( f)
215215 }
216216
217+ #[ unstable( feature = "once_cell_try" , issue = "109737" ) ]
217218 pub fn get_mut_or_try_init < F , E > ( & mut self , f : F ) -> Result < & mut T , E >
218219 where
219220 F : FnOnce ( ) -> Result < T , E > ,
@@ -228,7 +229,7 @@ impl<T> OnceCell<T> {
228229 // Avoid inlining the initialization closure into the common path that fetches
229230 // the already initialized value
230231 #[ cold]
231- fn try_init < F , E > ( & self , f : F ) -> Result < ( ) , E >
232+ fn try_init < F , E > ( & self , f : F ) -> Result < & T , E >
232233 where
233234 F : FnOnce ( ) -> Result < T , E > ,
234235 {
You can’t perform that action at this time.
0 commit comments