Struct main_error::MainError[][src]

pub struct MainError(_);
Expand description

Newtype wrapper around a boxed std::error::Error.

  • It implements Debug so that it can be used in fn main() -> Result<(), MainError>.
  • It implements From<E> for E: Into<Box<dyn Error>> so that it works as a drop-in for any type that can be converted into a boxed Error (i.e., an Error trait object).

MainError can only be constructed through its From impl: Explicitly with from/into or implicitly through the ? operator.

Example

Explicit construction via MainError::from:

let e = MainError::from("something convertible to Box<dyn Error>");

Or via into() when the target type can be inferred from the context:

fn main() -> Result<(), MainError> {
    Err("something convertible to Box<dyn Error>".into())
}

Or even easier via ?:

fn main() -> Result<(), MainError> {
    Err("something convertible to Box<dyn Error>")?
}

Trait Implementations

Formats the value using the given formatter. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.