use std::collections::HashMap;
pub struct ProjectStats {
pub language_line_map: HashMap<String, u32>, pub total_files: u32,
pub total_lines: u32,
pub total_bytes: u64,
}
impl ProjectStats {
pub fn new() -> Self {
ProjectStats {
language_line_map: HashMap::new(),
total_files: 0,
total_lines: 0,
total_bytes: 0,
}
}
pub fn add(&mut self, lang_id: String, lines: u32, bytes: u64) {
*self.language_line_map.entry(lang_id).or_insert(0) += lines;
self.total_files += 1;
self.total_lines += lines;
self.total_bytes += bytes;
}
pub fn merge(&mut self, other: &ProjectStats) {
for (lang, &lines) in &other.language_line_map {
*self.language_line_map.entry(lang.clone()).or_insert(0) += lines;
}
self.total_files += other.total_files;
self.total_lines += other.total_lines;
self.total_bytes += other.total_bytes;
}
}