IntoOk

Trait IntoOk 

Source
pub trait IntoOk
where Self: Sized,
{ // Required method fn into_ok<E>(self) -> Result<Self, E>; }
Expand description

A trait for converting a value into a Result::Ok variant.

This trait provides a convenient way to wrap any value in a Result::Ok, which can be useful in contexts where a Result is expected but you have a value that cannot fail.

§Examples

use cutoff_common::IntoOk;

let value = 42;
let result: Result<i32, &str> = value.into_ok();
assert_eq!(result, Ok(42));

Required Methods§

Source

fn into_ok<E>(self) -> Result<Self, E>

Converts self into a Result::Ok variant.

§Type Parameters
  • E - The error type for the resulting Result.
§Returns

A Result with self wrapped in the Ok variant.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> IntoOk for T
where Self: Sized,