Enum Pattern
pub enum Pattern
Transformations on a list of words.
A pattern is a function that maps a list of words into another list after changing the casing of each letter. How a patterns mutates each letter can be dependent on the word the letters are present in.
Custom Pattern
A pattern is a function that maps from a borrowed list of words &[&str] to
an owned list of owned words Vec<String> by applying a transformation.
One example of custom behavior might be a pattern
that detects a fixed list of two-letter acronyms, and capitalizes them
appropriately on output.
use ;
let acronym_converter = new
.set_pattern;
assert_eq!;
assert_eq!;
Another example might be a one that explicitly adds leading and trailing double underscores. We do this by modifying the words directly, which will get passed as-is to the join function.
use ;
let dunder_converter = new
.set_pattern
.set_delim;
assert_eq!;
assert_eq!;
Variants
-
Noop The no-op pattern performs no mutations.
# use Pattern; assert_eq!;-
Lowercase Makes all words lowercase.
# use Pattern; assert_eq!;-
Uppercase Makes all words uppercase.
# use Pattern; assert_eq!;-
Capital Makes the first letter of each word uppercase and the remaining letters of each word lowercase.
# use Pattern; assert_eq!;-
Camel Makes the first non-empty word lowercase and the remaining capitalized.
# use Pattern; assert_eq!;-
Sentence Makes the first non-empty word capitalized and the remaining lowercase.
# use Pattern; assert_eq!;-
Custom(fn(&[&str]) -> Vec<String>) Define custom behavior to transform a set of words.
See the
Patterndocumentation for examples.
Implementations
impl Pattern
fn mutate(&self, words: &[&str]) -> Vec<String>Applies the pattern transformation to a list of words.
Trait Implementations
impl Clone for Pattern
fn clone(&self) -> Pattern
impl Copy for Pattern
impl Debug for Pattern
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Pattern
impl Hash for Pattern
fn hash<__H: Hasher>(&self, state: &mut __H)
impl PartialEq for Pattern
fn eq(&self, other: &Pattern) -> bool
impl StructuralPartialEq for Pattern
Auto Trait Implementations
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnsafeUnpin for Pattern
impl UnwindSafe for Pattern
Blanket Implementations
impl<T> Any for Pattern
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Pattern
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Pattern
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Pattern
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Pattern
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Pattern
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Pattern
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Pattern
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Pattern
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>