4 ms·
> The main point is that your function can only return either a success or a failure. Failure should be handled using the throw statement so as to throw an exce
by Octokiddie 4y ago
> The main point is that your function can only return either a success or a failure. Failure should be handled using the throw statement so as to throw an exception, while success is what leads to another function, which can be of any type.
Rust bakes this into the language with the Result type. You signal railway oriented programming by returning a Result, which contains either the thing you want or an error. If you try to get the thing, you must deal with the possibility of an error in some way. There is no half-way.