Skip to main content

ChangeError

Trait ChangeError 

Source
pub trait ChangeError<T> {
    // Required method
    fn set_error(self, s: &str) -> Result<T, String>;
}
Expand description

Import this trait to get the set_error method on Results and Options

§Examples

use set_error::ChangeError;
let foo: Option<u32> = None;
assert_eq!(Err(String::from("erorr")), foo.set_error("erorr"));

Required Methods§

Source

fn set_error(self, s: &str) -> Result<T, String>

If an error is present it is replaced with the string passed into this method.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, E> ChangeError<T> for Result<T, E>

Source§

fn set_error(self, s: &str) -> Result<T, String>

Source§

impl<T> ChangeError<T> for Option<T>

Source§

fn set_error(self, s: &str) -> Result<T, String>

Implementors§