Skip to main content

OptionStringRef

Trait OptionStringRef 

Source
pub trait OptionStringRef<'o> {
    // Required method
    fn as_str(&'o self) -> Option<&'o str>;
}
Expand description

Extension trait for optional string types. Adds the as_str() extension method onto owned string Option values.

use ref_map::*;

let maybe_string = Some(String::from("foo_bar"));
let maybe_str: Option<&str> = maybe_string.as_str();

Required Methods§

Source

fn as_str(&'o self) -> Option<&'o str>

Borrows the internal (probably owned) string as an Option.

Implementations on Foreign Types§

Source§

impl<'o> OptionStringRef<'o> for Option<&'o str>

Source§

fn as_str(&'o self) -> Option<&'o str>

Source§

impl<'o> OptionStringRef<'o> for Option<Cow<'o, str>>

Source§

fn as_str(&'o self) -> Option<&'o str>

Source§

impl<'o> OptionStringRef<'o> for Option<String>

Source§

fn as_str(&'o self) -> Option<&'o str>

Implementors§