3 ms·
> Why define functions as variables? I'm not sure what you mean here, exactly. > Why .parent().unwrap().parent().unwrap()? I'm not mega familiar with the c
by steveklabnik 11y ago
> Why define functions as variables?
I'm not sure what you mean here, exactly.
> Why .parent().unwrap().parent().unwrap()?
I'm not mega familiar with the code, but using a low-level binding to something else that has nulls often means a lot of Option, which means a lot of unwrapping. A nicer library could probably get rid of some of this.
- 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.