Skip to content

Commit 77c6d26

Browse files
committed
mock stability attribute
Signed-off-by: tison <[email protected]>
1 parent a5f6409 commit 77c6d26

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

library/core/src/cell/once.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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
{

0 commit comments

Comments
 (0)