Trait Casing

Source
pub trait Casing: ToOwned {
    type Character: Copy + Eq;

    // Required methods
    fn upper(&self, _: Locale) -> Cow<'_, Self>;
    fn lower(&self, _: Locale) -> Cow<'_, Self>;
    fn capitalized(&self, _: Locale) -> Cow<'_, Self>;
    fn camel(
        &self,
        separators: Separator<&[Self::Character]>,
        mode: Camel,
        _: Locale,
    ) -> Cow<'_, Self>;
    fn separated(
        &self,
        separator: Separator<Self::Character>,
        _: Locale,
    ) -> Cow<'_, Self>;
    fn header(&self, _: Locale) -> Cow<'_, Self>;
}
Expand description

Trait with casing extensions.

Required Associated Types§

Required Methods§

Source

fn upper(&self, _: Locale) -> Cow<'_, Self>

Turns Self to upper case avoiding allocations if nothing would change.

Source

fn lower(&self, _: Locale) -> Cow<'_, Self>

Turns Self to lower case avoiding allocations if nothing would change.

Source

fn capitalized(&self, _: Locale) -> Cow<'_, Self>

Turns Self to its capitalized version, turning the first character to upper case and the rest to lower case.

Source

fn camel( &self, separators: Separator<&[Self::Character]>, mode: Camel, _: Locale, ) -> Cow<'_, Self>

Turns Self to camel case using the passed Separator to know which symbols should mark a new word.

Source

fn separated( &self, separator: Separator<Self::Character>, _: Locale, ) -> Cow<'_, Self>

Turns Self to a case separated by the given separator, using Separator('_') would turn to snake case, using Separator('-') would turn to dashed case.

Source

fn header(&self, _: Locale) -> Cow<'_, Self>

Turns Self to header case, where each word is separated by '-' and starts with an upper case character. Upper case characters after the first are not lower cased.

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 Casing for str

Source§

type Character = char

Source§

fn upper(&self, _locale: Locale) -> Cow<'_, Self>

Source§

fn lower(&self, _locale: Locale) -> Cow<'_, Self>

Source§

fn capitalized(&self, _locale: Locale) -> Cow<'_, Self>

Source§

fn camel( &self, separator: Separator<&[char]>, mode: Camel, _locale: Locale, ) -> Cow<'_, Self>

Source§

fn separated( &self, separator: Separator<char>, _locale: Locale, ) -> Cow<'_, Self>

Source§

fn header(&self, _locale: Locale) -> Cow<'_, Self>

Source§

impl Casing for [u8]

Source§

type Character = u8

Source§

fn upper(&self, _locale: Locale) -> Cow<'_, Self>

Source§

fn lower(&self, _locale: Locale) -> Cow<'_, Self>

Source§

fn capitalized(&self, _locale: Locale) -> Cow<'_, Self>

Source§

fn camel( &self, separator: Separator<&[u8]>, mode: Camel, _locale: Locale, ) -> Cow<'_, Self>

Source§

fn separated(&self, separator: Separator<u8>, _locale: Locale) -> Cow<'_, Self>

Source§

fn header(&self, _locale: Locale) -> Cow<'_, Self>

Implementors§