big flemme faire une pr pour ca

This commit is contained in:
lilymonade 2025-03-11 18:57:14 +01:00
parent cb59d215cb
commit 880d779e6c
Signed by: lilymonade
GPG Key ID: F8967EC454DBDCB6

View File

@ -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/).