Initial upload: GitPulse - Developer Productivity Analyzer CLI tool
This commit is contained in:
32
src/utils/mod.rs
Normal file
32
src/utils/mod.rs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
pub mod author;
|
||||||
|
pub mod formatting;
|
||||||
|
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
pub fn normalize_email(email: &str) -> String {
|
||||||
|
let email = email.to_lowercase();
|
||||||
|
email.trim().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn normalize_name(name: &str) -> String {
|
||||||
|
let name = name.trim();
|
||||||
|
let mut result = String::new();
|
||||||
|
let mut capitalize = true;
|
||||||
|
for c in name.chars() {
|
||||||
|
if c.is_whitespace() {
|
||||||
|
capitalize = true;
|
||||||
|
result.push(c);
|
||||||
|
} else if capitalize {
|
||||||
|
result.push(c.to_ascii_uppercase());
|
||||||
|
capitalize = false;
|
||||||
|
} else {
|
||||||
|
result.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_unique_items<T: std::hash::Hash + Eq>(items: &[T]) -> Vec<&T> {
|
||||||
|
let seen: HashSet<&T> = items.iter().collect();
|
||||||
|
seen.into_iter().collect()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user