mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-16 12:52:24 +02:00
Added numbers and ranges to mapping
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user