Hacker News new | past | comments | ask | show | jobs | submit login

One is undefined behavior which may manifest as entirely unpredictable side-effects. The other has semantics that are well specified and predictable. Also while what you wrote is technically valid, it's not really idiomatic to write it the way you did in Rust, you usually write it as:

    if let Some(value) = some_optional {
    }
At which point value is the "dereferenced" value. Or you can take it by reference if you don't want to consume the value.



I prefer ok_or for optionals and map_err for for results in Rust. I believe the way you proposed ends up with very deeply nested code which I try to avoid.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: