Trait try_default::TryDefault[][src]

pub trait TryDefault<V> {
    fn try_default() -> Option<V>;
}

A trait for all types!

If the type has a Default value,

    use ::try_default::TryDefault;

    // Set to `Some(0)`.
    let default_num = <u32>::try_default();

    // Set to `None`, as `::std::fs::File` has no `Default`.
    let default_file = <::std::fs::File>::try_default();

Required methods

fn try_default() -> Option<V>[src]

If the implementor implements Default, then this will return Option::Some(Default::default()).

Otherwise it returns Option::None.

Loading content...

Implementors

impl<V> TryDefault<V> for V[src]

impl<V: Default> TryDefault<V> for V[src]

Loading content...