Trait ExpectedResult

Source
pub trait ExpectedResult<T>
where Self: Sized,
{ // Required method fn expect_result_nb<F>(self, msgf: F) -> Result<T, ExpectationFailed> where F: FnOnce() -> String; // Provided methods fn expect_result_nb_(self, msg: &str) -> Result<T, ExpectationFailed> { ... } fn expect_result_(self, msg: &str) -> Result<T, Box<dyn Error>> { ... } fn expect_result<F>(self, msgf: F) -> Result<T, Box<dyn Error>> where F: FnOnce() -> String { ... } }
👎Deprecated: This module is in maintenance mode; the anyhow library might be a better choice
Expand description

Test the value and return a result object containing either the inner value or an error object that, when displayed, will provide the specified error message.

Required Methods§

Source

fn expect_result_nb<F>(self, msgf: F) -> Result<T, ExpectationFailed>
where F: FnOnce() -> String,

👎Deprecated: This module is in maintenance mode; the anyhow library might be a better choice

Return a result object with a non-boxed Error object. Invoke the specified function to obtain the error message.

§Errors

ExpectationFailed on error.

Provided Methods§

Source

fn expect_result_nb_(self, msg: &str) -> Result<T, ExpectationFailed>

👎Deprecated: This module is in maintenance mode; the anyhow library might be a better choice

Return a result object with a non-boxed Error object.

§Errors

ExpectationFailed on error.

Source

fn expect_result_(self, msg: &str) -> Result<T, Box<dyn Error>>

👎Deprecated: This module is in maintenance mode; the anyhow library might be a better choice

Return a result object that may be tested using the ? operator.

§Errors

ExpectationFailed on error.

Source

fn expect_result<F>(self, msgf: F) -> Result<T, Box<dyn Error>>
where F: FnOnce() -> String,

👎Deprecated: This module is in maintenance mode; the anyhow library might be a better choice

Return a result object that may be tested using the ? operator. Invoke the specified function to obtain the error message.

§Errors

ExpectationFailed on error.

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.

Implementations on Foreign Types§

Source§

impl ExpectedResult<()> for bool

Source§

fn expect_result_nb<F>(self, msgf: F) -> Result<(), ExpectationFailed>
where F: FnOnce() -> String,

👎Deprecated: This module is in maintenance mode; the anyhow library might be a better choice
Source§

impl<T> ExpectedResult<T> for Option<T>

Source§

fn expect_result_nb<F>(self, msgf: F) -> Result<T, ExpectationFailed>
where F: FnOnce() -> String,

👎Deprecated: This module is in maintenance mode; the anyhow library might be a better choice
Source§

impl<T, E> ExpectedResult<T> for Result<T, E>
where E: Display,

Source§

fn expect_result_nb<F>(self, msgf: F) -> Result<T, ExpectationFailed>
where F: FnOnce() -> String,

👎Deprecated: This module is in maintenance mode; the anyhow library might be a better choice

Implementors§