Trait TryDefault

Source
pub trait TryDefault: Sized {
    // Required method
    fn try_default() -> Result<Self, String>;

    // Provided method
    fn unwrap_default() -> Self { ... }
}
Expand description

Tries to create a default value, returns an Err with the name of the storage and/or component if there’s no default.

Required Methods§

Source

fn try_default() -> Result<Self, String>

Tries to create the default.

Provided Methods§

Source

fn unwrap_default() -> Self

Calls try_default and panics on an error case.

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.

Implementors§

Source§

impl<T> TryDefault for T
where T: Default,