[][src]Enum tao_of_rust::ch02::generics_trait::Option

pub enum Option<T> {
    Some(T),
    None,
}

std::option::Option 定义

Basic usage:

use std::fmt::Debug;
fn match_option<T: Debug>(o: Option<T>) {
    match o {
        Some(i) => println!("{:?}", i),
        None => println!("nothing"),
    }
}
let a: Option<i32> = Some(3);
let b: Option<&str> = Some("hello");
let c: Option<char> = Some('A');
let d: Option<u32>  = None;

match_option(a);  // 3
match_option(b);  // "hello"
match_option(c);  // 'A'
match_option(d);  // nothingRun

Variants

Auto Trait Implementations

impl<T> Send for Option<T> where
    T: Send

impl<T> Sync for Option<T> where
    T: Sync

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.