Stupid

Trait Stupid 

Source
pub trait Stupid<T: ToString> {
    // Required methods
    fn alternate_case(&self) -> Option<T>;
    fn invert_case(&self) -> Option<T>;
    fn vapor_wave(&self) -> Option<T>;
    fn shuffle(&self) -> Option<T>;
    fn alphabetical(&self) -> Option<T>;
}

Required Methods§

Source

fn alternate_case(&self) -> Option<T>

Source

fn invert_case(&self) -> Option<T>

Source

fn vapor_wave(&self) -> Option<T>

Source

fn shuffle(&self) -> Option<T>

Source

fn alphabetical(&self) -> Option<T>

Implementations on Foreign Types§

Source§

impl Stupid<String> for String

Source§

fn alternate_case(&self) -> Option<String>

§Examples:
use string_stupidify::Stupid;

let alternating = String::from("abcde").alternate_case().unwrap();
assert_eq!("AbCdE", alternating.as_str());

This function will ignore non-alphabetic characters:

use string_stupidify::Stupid;

let alternating = String::from("abc.de f34ghßi").alternate_case().unwrap();
assert_eq!("AbC.dE f34GhSSi", alternating.as_str());
Source§

fn invert_case(&self) -> Option<String>

§Example:
use string_stupidify::Stupid;

let inverted = String::from("aBc.de F").invert_case().unwrap();
assert_eq!("AbC.DE f", inverted);
Source§

fn vapor_wave(&self) -> Option<String>

§Example:
use string_stupidify::Stupid;

let vaporized = String::from("abCD eF").vapor_wave().unwrap();
assert_eq!("A B C D   E F", vaporized.as_str());
Source§

fn shuffle(&self) -> Option<String>

§Example:
use string_stupidify::Stupid;

let shuffled = String::from("abcdeba").shuffle().unwrap();
assert_ne!("abcdeba", shuffled);
assert_eq!(7, shuffled.len());
assert_eq!(2, shuffled.matches("a").count());
assert_eq!(2, shuffled.matches("b").count());
assert_eq!(1, shuffled.matches("c").count());
assert_eq!(1, shuffled.matches("d").count());
assert_eq!(1, shuffled.matches("e").count());

Single char or empty Strings return a copy of the String:

use string_stupidify::Stupid;

assert_eq!("", "".to_string().shuffle().unwrap());
assert_eq!("a", "a".to_string().shuffle().unwrap());

Strings with only one repeated char are also returning a copy:

use string_stupidify::Stupid;

assert_eq!("aaaaa", "aaaaa".to_string().shuffle().unwrap());
Source§

fn alphabetical(&self) -> Option<String>

§Example:
use string_stupidify::Stupid;

let sorted = String::from("basbc").alphabetical().unwrap();
assert_eq!("abbcs", sorted);

Implementors§