Skip to content

Commit a4c30c4

Browse files
committed
make borrow checker happy
Signed-off-by: tison <[email protected]>
1 parent 77c6d26 commit a4c30c4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

library/core/src/cell/once.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,9 @@ impl<T> OnceCell<T> {
219219
where
220220
F: FnOnce() -> Result<T, E>,
221221
{
222-
if let Some(val) = self.get_mut() {
223-
return Ok(val);
222+
if self.get().is_none() {
223+
self.try_init(f)?;
224224
}
225-
self.try_init(f)?;
226225
Ok(self.get_mut().unwrap())
227226
}
228227

0 commit comments

Comments
 (0)