big flemme faire une pr pour ca
This commit is contained in:
parent
cb59d215cb
commit
880d779e6c
@ -6,7 +6,7 @@ file = "src/errors/result.rs"
|
||||
We saw earlier the `Option` type, which represents a possibly absent value (sometimes called "nullable" in other languages). Now it would be useful to carry **the reason** of this absence of value. Let's say you are parsing an integer from a `String`, there are multiple ways it can fail.
|
||||
|
||||
- The string contains invalid characters (non-digits).
|
||||
- The value we want to parse is too large (for example, trying to parse `"999999999999"` as an i32).
|
||||
- The value we want to parse is too large (for example, trying to parse `"999999999999"` as an `i32`).
|
||||
|
||||
If we want to react properly, we need to know why it failed. So instead of having only `None` as output, we would like a variant like `SomeError(v)`. In Rust, this type with `Some` and `SomeError` variants is called [`Result`](https://doc.rust-lang.org/std/result/).
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user