Rust Into Option

Using Option in Rust can produce cumbersome to use APIs.

It's possible to get around that using Into<Option>.

fn hello(name: impl Into<Option<&'static str>>) {
    match name.into() {
        Some(name) => println!("Hello, {}!", name),
        None => println!("Who are you?"),
    }
}

fn main() {
    hello("Bob");
    hello(None);
}

Of course if you could also use generics over impl Trait.

Limitations