Trait StringOrStr

Source
pub trait StringOrStr<'a>:
    AsRef<str>
    + From<&'a str>
    + Debug
    + Display
    + Eq
    + Hash
    + Clone
    + for<'b> PartialEq<&'b str> {
    // Required methods
    fn strip_prefix(self, s: &str) -> Result<Self, Self>;
    fn split_n(self, n: usize) -> (Self, Self);
    fn trim_ws(&mut self);
    fn split_noparens<const OPEN: char, const CLOSE: char>(
        &'a self,
        split_char: char,
    ) -> impl Iterator<Item = &'a str>;
    fn as_cow(&self) -> Cow<'a, str>;
}

Required Methodsยง

Source

fn strip_prefix(self, s: &str) -> Result<Self, Self>

ยงErrors

Will return Err if self does not start with prefix.

Source

fn split_n(self, n: usize) -> (Self, Self)

Source

fn trim_ws(&mut self)

Source

fn split_noparens<const OPEN: char, const CLOSE: char>( &'a self, split_char: char, ) -> impl Iterator<Item = &'a str>

Source

fn as_cow(&self) -> Cow<'a, str>

Dyn Compatibilityยง

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Typesยง

Sourceยง

impl<'a> StringOrStr<'a> for &'a str

Sourceยง

fn strip_prefix(self, s: &str) -> Result<Self, Self>

Sourceยง

fn split_n(self, n: usize) -> (Self, Self)

Sourceยง

fn trim_ws(&mut self)

Sourceยง

fn split_noparens<const OPEN: char, const CLOSE: char>( &'a self, split_char: char, ) -> impl Iterator<Item = &'a str>

Sourceยง

fn as_cow(&self) -> Cow<'a, str>

Sourceยง

impl<'a> StringOrStr<'a> for String

Sourceยง

fn strip_prefix(self, s: &str) -> Result<Self, Self>

Sourceยง

fn trim_ws(&mut self)

Sourceยง

fn split_n(self, n: usize) -> (Self, Self)

Sourceยง

fn split_noparens<const OPEN: char, const CLOSE: char>( &'a self, split_char: char, ) -> impl Iterator<Item = &'a str>

Sourceยง

fn as_cow(&self) -> Cow<'a, str>

Implementorsยง