4 ms·
From the left-hand side of the `=>` arrows in the `match` expression.
by maxbrunsfeld 11y ago
From the left-hand side of the `=>` arrows in the `match` expression.
- msie 11y agoI know that. Where do they come from before that?
- steveklabnik 11y agomatch number_str.parse::<i32>() { This matches on the return value of parse, which is an Result<T>. It can have two values: Err(E), or Ok(T). Ok(n) => Ok(2 * n), This line matches an Ok(T), and binds the value of type T to n, which can then be used on the right hand side. Err(err) => Err(err), this line matches an Err(T), and binds the value of type T to err, which can be used on the right hand side. The right hand sides re-wrap these values into another Result.
- phaylon 11y agoNitpick: Result<T, E> instead of Result<T> assuming Result is std::result::Result.
- steveklabnik 11y agoAhh yes, thank you.
- msie 11y agoThanks!
- deleted 11y ago[deleted]