pub type Result<T = (), E = Error> = Result<T, E>;Expand description
A Result with an Error error type.
To be used as the return type for functions that may fail.
§Error codes in C and Rust
In C, it is common that functions indicate success or failure through
their return value; modifying or returning extra data through non-const
pointer parameters. In particular, in the kernel, functions that may fail
typically return an int that represents a generic error code. We model
those as Error.
In Rust, it is idiomatic to model functions that may fail as returning
a Result. Since in the kernel many functions return an error code,
Result is a type alias for a core::result::Result that uses
Error as its error type.
Note that even if a function does not return anything when it succeeds,
it should still be modeled as returning a Result rather than
just an Error.
Aliased Type§
enum Result<T = (), E = Error> {
Ok(T),
Err(E),
}