Trait OptionExt

pub trait OptionExt {
    // Required method
    fn display(&self) -> String;
}
Expand description

Extends Option for easy display formatting

Required Methods§

fn display(&self) -> String

Better option outputs

Generic over anything that implements Display, this will either be the value contained within Some() or “none” for the None variant.

For example:

let x: Option<u32> = Some(2);
assert_eq!(x.display(), "2");

let x: Option<u32> = None;
assert_eq!(x.display(), "none");

Implementations on Foreign Types§

§

impl<T: Display> OptionExt for Option<T>

§

fn display(&self) -> String

Implementors§