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