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 infn main() -> Result<(), MainError>
. - It implements
From<E>
forE: Into<Box<dyn Error>>
so that it works as a drop-in for any type that can be converted into a boxedError
(i.e., anError
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>")?
}