Skip to main content

Crate maybe_trait

Crate maybe_trait 

Source
Expand description

This crate provides the Maybe trait which is implemented for both T and Option<T>. The purpose is so that you can write functions like this:

fn foo(param: impl Maybe<Foo>) {
    if let Some(value) = param.maybe() {
        do_something_with(value)
    } else {
        do_something_else()
    }
}

This way you never need to write foo(Some(x)).

Traitsยง

Maybe