Enum collections::str::MaybeOwned[src]

pub enum MaybeOwned<'a> {
    Slice(&'a str),
    Owned(String),
}

A MaybeOwned is a string that can hold either a String or a &str. This can be useful as an optimization when an allocation is sometimes needed but not always.

Variants

Slice

A borrowed string

Owned

An owned string

Methods

impl<'a> MaybeOwned<'a>

fn is_owned(&self) -> bool

Returns true if this MaybeOwned wraps an owned string

fn is_slice(&self) -> bool

Returns true if this MaybeOwned wraps a borrowed string

Trait Implementations

impl<'a> IntoMaybeOwned<'a> for MaybeOwned<'a>

fn into_maybe_owned(self) -> MaybeOwned<'a>

impl<'a> PartialEq for MaybeOwned<'a>

fn eq(&self, other: &MaybeOwned) -> bool

fn ne(&self, other: &Self) -> bool

impl<'a> Eq for MaybeOwned<'a>

impl<'a> PartialOrd for MaybeOwned<'a>

fn lt(&self, other: &MaybeOwned) -> bool

fn le(&self, other: &Self) -> bool

fn gt(&self, other: &Self) -> bool

fn ge(&self, other: &Self) -> bool

impl<'a> Ord for MaybeOwned<'a>

fn cmp(&self, other: &MaybeOwned) -> Ordering

impl<'a, S: Str> Equiv<S> for MaybeOwned<'a>

fn equiv(&self, other: &S) -> bool

impl<'a> Str for MaybeOwned<'a>

fn as_slice<'b>(&'b self) -> &'b str

impl<'a> StrAllocating for MaybeOwned<'a>

fn into_string(self) -> String

fn to_string(&self) -> String

fn into_owned(self) -> String

fn escape_default(&self) -> String

fn escape_unicode(&self) -> String

fn replace(&self, from: &str, to: &str) -> String

fn to_owned(&self) -> String

fn to_utf16(&self) -> Vec<u16>

fn repeat(&self, nn: uint) -> String

fn lev_distance(&self, t: &str) -> uint

fn nfd_chars<'a>(&'a self) -> Decompositions<'a>

fn nfkd_chars<'a>(&'a self) -> Decompositions<'a>

impl<'a> Collection for MaybeOwned<'a>

fn len(&self) -> uint

fn is_empty(&self) -> bool

impl<'a> Clone for MaybeOwned<'a>

fn clone(&self) -> MaybeOwned<'a>

fn clone_from(&mut self, source: &Self)

impl<'a> Default for MaybeOwned<'a>

fn default() -> MaybeOwned<'a>

impl<'a, H: Writer> Hash<H> for MaybeOwned<'a>

fn hash(&self, hasher: &mut H)

impl<'a> Show for MaybeOwned<'a>

fn fmt(&self, f: &mut Formatter) -> Result