pub trait NewFrom {
type Builder;
// Required methods
fn new() -> Self::Builder;
fn from_super(e: Box<dyn Exception>) -> Self
where Self: Sized;
}Expand description
§New or From Exception
Use this trait to create an Exception
§example
impl NewFrom for SuperException {
type Builder = SuperBuilder;
fn new() -> Self::Builder {
SuperBuilder::new()
}
fn from(e: Box<dyn Exception>) -> Self where Self: Sized {
SuperException {
code: e.code(),
msg: String::from(e.msg()),
level: e.level(),
}
}
}Required Associated Types§
Required Methods§
Sourcefn from_super(e: Box<dyn Exception>) -> Selfwhere
Self: Sized,
fn from_super(e: Box<dyn Exception>) -> Selfwhere
Self: Sized,
create a new Exception from any Exception
- can convert from : supper
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.