|
hoshi-lang dev
Yet another programming language
|
The Result<T, E> type is a standard library feature in Hoshi-lang for functions that can return either a value or an error.
The Result<T, E> struct is an enumeration with two variants:
Ok(T): Represents success and contains a value of type T.Err(E): Represents an error and contains a value of type E.is_ok() : bool: Returns true if the result is Ok.is_err() : bool: Returns true if the result is Err.unwrap() : T: Returns the value inside an Ok. Panics if the result is Err.unwrap_err() : E: Returns the error inside an Err. Panics if the result is Ok.ok(value: T) : Result<T, E>: Creates an Ok result.err(error: E) : Result<T, E>: Creates an Err result.