Skip to main content

StringOrStr

Trait StringOrStr 

Source
pub trait StringOrStr<'a>:
    AsRef<str>
    + From<&'a str>
    + Debug
    + Display
    + Eq
    + Hash
    + Clone
    + for<'b> PartialEq<&'b str>
    + Into<Cow<'a, str>> {
    const IS_STR: bool;

    // 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_bytes(
        &'a self,
        open: u8,
        close: u8,
        split_char: u8,
    ) -> impl Iterator<Item = &'a str>;
    fn split_noparens(
        &'a self,
        open: char,
        close: char,
        split_char: char,
    ) -> impl Iterator<Item = &'a str>;
    fn as_cow(&self) -> Cow<'a, str>;
}

Required Associated Constantsยง

Source

const IS_STR: bool

Self == &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_bytes( &'a self, open: u8, close: u8, split_char: u8, ) -> impl Iterator<Item = &'a str>

Source

fn split_noparens( &'a self, open: char, close: char, 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".

Implementations on Foreign Typesยง

Sourceยง

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

Sourceยง

const IS_STR: bool = true

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_bytes( &'a self, open: u8, close: u8, split_char: u8, ) -> impl Iterator<Item = &'a str>

Sourceยง

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

Sourceยง

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

Sourceยง

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

Sourceยง

const IS_STR: bool = false

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_bytes( &'a self, open: u8, close: u8, split_char: u8, ) -> impl Iterator<Item = &'a str>

Sourceยง

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

Sourceยง

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

Implementorsยง