Skip to content

Commit

Permalink
Fix OnceCell::take not reverting the inner state
Browse files Browse the repository at this point in the history
This would result in a panic from an unwrap when attempting to
re-initialize the cell.
  • Loading branch information
danieldg committed Jul 17, 2022
1 parent 8bf2d3f commit 65219fa
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ impl<T> OnceCell<T> {

/// Takes the value out of this `OnceCell`, moving it back to an uninitialized state.
pub fn take(&mut self) -> Option<T> {
self.inner = Inner::new();
self.value.get_mut().take()
}

Expand Down

0 comments on commit 65219fa

Please sign in to comment.