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> {
165
165
}
166
166
167
167
#[ inline]
168
+ #[ stable( feature = "once_cell" , since = "1.70.0" ) ]
168
169
pub fn get_mut_or_init < F > ( & mut self , f : F ) -> & mut T
169
170
where
170
171
F : FnOnce ( ) -> T ,
@@ -210,10 +211,10 @@ impl<T> OnceCell<T> {
210
211
if let Some ( val) = self . get ( ) {
211
212
return Ok ( val) ;
212
213
}
213
- self . try_init ( f) ?;
214
- Ok ( self . get ( ) . unwrap ( ) )
214
+ self . try_init ( f)
215
215
}
216
216
217
+ #[ unstable( feature = "once_cell_try" , issue = "109737" ) ]
217
218
pub fn get_mut_or_try_init < F , E > ( & mut self , f : F ) -> Result < & mut T , E >
218
219
where
219
220
F : FnOnce ( ) -> Result < T , E > ,
@@ -228,7 +229,7 @@ impl<T> OnceCell<T> {
228
229
// Avoid inlining the initialization closure into the common path that fetches
229
230
// the already initialized value
230
231
#[ cold]
231
- fn try_init < F , E > ( & self , f : F ) -> Result < ( ) , E >
232
+ fn try_init < F , E > ( & self , f : F ) -> Result < & T , E >
232
233
where
233
234
F : FnOnce ( ) -> Result < T , E > ,
234
235
{
You can’t perform that action at this time.
0 commit comments