Added numbers and ranges to mapping

This commit is contained in:
euzu
2025-05-26 10:43:03 +02:00
parent 0b2c6b75ea
commit fec6f21632
4 changed files with 262 additions and 34 deletions
+5 -10
View File
@@ -20,10 +20,12 @@ pub trait Capitalize {
}
// Implement the Capitalize trait for &str
impl Capitalize for &str {
impl<T: AsRef<str>> Capitalize for T {
fn capitalize(&self) -> String {
let mut chars = self.chars();
let first = chars.next()
let s = self.as_ref();
let mut chars = s.chars();
let first = chars
.next()
.map(|c| c.to_uppercase().collect::<String>())
.unwrap_or_default();
let rest = chars.as_str().to_lowercase();
@@ -31,13 +33,6 @@ impl Capitalize for &str {
}
}
// Implement the trait for String as well
impl Capitalize for String {
fn capitalize(&self) -> String {
self.as_str().capitalize() // Reuse the &str implementation
}
}
pub fn get_trimmed_string(value: &Option<String>) -> Option<String> {
if let Some(v) = value {
let trimmed = v.trim();