Closed manuthambi closed 5 years ago
On second thought, there isn't much point in returning an uninitialized OnceCell if the unwrap fails.
So the signature could be:
pub fn try_unwrap(self) -> Option<T>
sgmt, though, I think the name and signature should be, to map RefCell
:
pub fn into_inner(self) -> Option<T>
into_inner
sounds better, and it is better to be consistent with RefCell
.
I haven't contributed to Rust before, but do you want me to send you a pull request?
Sure, that would be awesome! Here's a checklist of things to do:
unsync
variantsync
variant
Add a method which consumes OnceCell and returns the element if it exists. The method signature can be very similar to Arc::try_unwrap().
pub fn try_unwrap(self) -> Result<T, OnceCell<T>>