2 ms·
Rust's error handling is pretty good. First of all you see in the signature of the function that it can trigger an exception, so such a function will return Res
by bad_user 11y ago
Rust's error handling is pretty good. First of all you see in the signature of the function that it can trigger an exception, so such a function will return Result<T, E> instead of just T. This is similar to Option, Either or Try in Scala, or to Maybe / Either in Haskell. To easily pipe such errors, Rust provides a try! macro, which just expands into a catch block.
Rust is less functional than Haskell or Scala, so I don't know how that works out, but in FP languages it ends up working great. Also, compared with Go it isn't the same thing.