3 ms·
>which means a lot of unwrapping .unwrap() In rust is generally a bad pattern to use. Its basically short hand for let o :Option< u64 >; let va
by valarauca1 11y ago
>which means a lot of unwrapping
.unwrap()
In rust is generally a bad pattern to use. Its basically short hand for
let o :Option< u64 >;
let value :u64 = match o {
Some( t ) => t,
None => panic!()
};
So if you don't met the condition, you explode. When ever you see .unwrap() in Rust just mentally switch it for /TODO add error handling */
- steveklabnik 11y agoYeah, I was just using "unwrapping" as a more general term for "extract the T out." We almost changed 'unwrap' to 'assert', but people found it a bit too weird.
- valarauca1 11y ago>We almost changed 'unwrap' to 'assert', but people found it a bit too weird. That is weird. idk I guess its already sort of being done, you're more or less asserting Option::Some( _ ) is the value.