Sha256: 1a0767b5ce121f044ea2abe8cb9b166285fa76bc0b8d210696f9cdf0a1e5f544
Contents?: true
Size: 381 Bytes
Versions: 395
Compression:
Stored size: 381 Bytes
Contents
use std::collections::HashMap; pub fn word_count(input: &str) -> HashMap<String, u32> { let mut map: HashMap<String, u32> = HashMap::new(); let lower = input.to_lowercase(); let slice: &str = lower.as_ref(); for word in slice.split(|c: char| !c.is_alphanumeric()).filter(|s| !s.is_empty()) { *map.entry(word.to_string()).or_insert(0) += 1; } map }
Version data entries
395 entries across 395 versions & 1 rubygems