ReCase

Struct ReCase 

Source
pub struct ReCase<'a> { /* private fields */ }
Expand description

An instance that holds the text to be re-cased.

§Example

let recase = recase::ReCase::new("Example String");
assert_eq!(recase.snake_case(), "example_string");          
assert_eq!(recase.upper_snake_case(), "EXAMPLE_STRING");

Implementations§

Source§

impl<'a> ReCase<'a>

Source

pub fn new(original_text: &'a str) -> Self

Examples found in repository?
examples/main.rs (line 9)
3fn main() {
4    const INPUT: &str = "Löng and meaningless-Ẽxample_Text";
5
6    // Using the Casing Trait
7    println!("{}", INPUT.to_kebab_case()); // Prints "löng-and-meaningless-ẽxample-text"
8
9    let recase = ReCase::new(INPUT);
10
11    println!("{}", recase.snake_case()); // Prints "löng_and_meaningless_ẽxample_text"
12    println!("{}", recase.camel_case()); // Prints "löngAndMeaninglessẼxampleText"
13}
Source

pub fn normal_case(&self) -> String

Returns a normal case version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.normal_case(), "example string");
Source

pub fn camel_case(&self) -> String

Returns a camelCase version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.camel_case(), "exampleString");
Examples found in repository?
examples/main.rs (line 12)
3fn main() {
4    const INPUT: &str = "Löng and meaningless-Ẽxample_Text";
5
6    // Using the Casing Trait
7    println!("{}", INPUT.to_kebab_case()); // Prints "löng-and-meaningless-ẽxample-text"
8
9    let recase = ReCase::new(INPUT);
10
11    println!("{}", recase.snake_case()); // Prints "löng_and_meaningless_ẽxample_text"
12    println!("{}", recase.camel_case()); // Prints "löngAndMeaninglessẼxampleText"
13}
Source

pub fn pascal_case(&self) -> String

Returns a PascalCase version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.pascal_case(), "ExampleString");
Source

pub fn snake_case(&self) -> String

Returns a snake_case version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.snake_case(), "example_string");
Examples found in repository?
examples/main.rs (line 11)
3fn main() {
4    const INPUT: &str = "Löng and meaningless-Ẽxample_Text";
5
6    // Using the Casing Trait
7    println!("{}", INPUT.to_kebab_case()); // Prints "löng-and-meaningless-ẽxample-text"
8
9    let recase = ReCase::new(INPUT);
10
11    println!("{}", recase.snake_case()); // Prints "löng_and_meaningless_ẽxample_text"
12    println!("{}", recase.camel_case()); // Prints "löngAndMeaninglessẼxampleText"
13}
Source

pub fn kebab_case(&self) -> String

Returns a kebab-case version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.kebab_case(), "example-string");
Source

pub fn dot_case(&self) -> String

Returns a dot.case version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.dot_case(), "example.string");
Source

pub fn path_case(&self) -> String

Returns a path/case version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.path_case(), "example/string");
Source

pub fn windows_path_case(&self) -> String

Returns a windows\path\case version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.windows_path_case(), "example\\string");
Source

pub fn sentence_case(&self) -> String

Returns a Sentence case version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.sentence_case(), "Example string");
Source

pub fn title_case(&self) -> String

Returns a Title Case version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.title_case(), "Example String");
Source

pub fn header_case(&self) -> String

Returns a Header-Case version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.header_case(), "Example-String");
Source

pub fn upper_snake_case(&self) -> String

Returns a UPPER_SNAKE_CASE version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.upper_snake_case(), "EXAMPLE_STRING");
Source

pub fn alternating_case(&self) -> String

Returns a AlTeRnAtInG cAsE version of the input text as a new String

§Example
let recase = recase::ReCase::new("Example String");
assert_eq!(recase.alternating_case(), "eXaMpLe StRiNg");

Trait Implementations§

Source§

impl<'a> Debug for ReCase<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ReCase<'a>

§

impl<'a> RefUnwindSafe for ReCase<'a>

§

impl<'a> Send for ReCase<'a>

§

impl<'a> Sync for ReCase<'a>

§

impl<'a> Unpin for ReCase<'a>

§

impl<'a> UnwindSafe for ReCase<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.