matklad / once_cell

Rust library for single assignment cells and lazy statics without macros
Apache License 2.0
1.84k stars 110 forks source link

Add try insert #151

Closed matklad closed 3 years ago

matklad commented 3 years ago

bors r+ 🤖

bors[bot] commented 3 years ago

Build failed:

matklad commented 3 years ago

bors r+

bors[bot] commented 3 years ago

Build succeeded:

correabuscar commented 5 months ago

I was surprised to see that set(value) returns the value that was attempted to be set in Err(value), especially since the try_insert that's based upon can return a ref to the value that was already set.

EDIT: perhaps it makes sense after all, if the intent is to return the ownership, hmm...