Closed jyn514 closed 1 year ago
The fully general signature would be Resut<&T, (&T, T)>. I think we should add this as an extra method (insert perhaps?).
Ok, naming is hard. We have Option::insert and Option::get_or_insert, which do different things. I think OnceCell::try_insert would probably be the right name for semantics we want here.
try_insert
now exists
Say I want to write a function like this:
Here's the current approach I have to use:
It would be nice to be able to remove the second unwrap:
but right now
set()
doesn't return that data, so I can't.