#[derive(Debug, Clone, Default)]
pub enum WordLength {
#[default]
None,
Chars(u8),
}
pub trait Word: AsRef<str> + Clone{
fn capitalize(&self) -> String {
let s = self.as_ref();
let mut c = s.chars();
match c.next() {
Some(first) => first.to_uppercase().collect::<String>() + c.as_str(),
None => String::new(),
}
}
}
impl Word for &'static str {
fn capitalize(&self) -> String {
let mut c = self.chars();
match c.next() {
Some(first) => first.to_uppercase().collect::<String>() + c.as_str(),
None => String::new(),
}
}
}
impl Word for String {
fn capitalize(&self) -> String {
let mut c = self.chars();
match c.next() {
Some(first) => first.to_uppercase().collect::<String>() + c.as_str(),
None => String::new(),
}
}
}