Skip to main content

Result

Enum Result 

1.6.0 · Source
pub enum Result<T, E> {
    Ok(T),
    Err(E),
}
Expand description

Result is a type that represents either success (Ok) or failure (Err).

See the module documentation for details.

Variants§

§1.6.0

Ok(T)

Contains the success value

§1.6.0

Err(E)

Contains the error value

Implementations§

Source§

impl<T, E> Result<T, E>

1.0.0 (const: 1.48.0) · Source

pub const fn is_ok(&self) -> bool

Returns true if the result is Ok.

§Examples
let x: Result<i32, &str> = Ok(-3);
assert_eq!(x.is_ok(), true);

let x: Result<i32, &str> = Err("Some error message");
assert_eq!(x.is_ok(), false);
1.70.0 (const: unstable) · Source

pub fn is_ok_and<F>(self, f: F) -> bool
where F: FnOnce(T) -> bool, T:, E:,

Returns true if the result is Ok and the value inside of it matches a predicate.