Memory-safe systems language with strong compile-time guarantees.
Rust is best when teams need predictable performance and strict safety. It is used in infrastructure layers, CLI tools, and services where failure modes are expensive.
Result and Option.use std::collections::HashMap;
fn count_words(text: &str) -> HashMap<&str, usize> {
let mut freq = HashMap::new();
for w in text.split_whitespace() {
*freq.entry(w).or_insert(0) += 1;
}
freq
}
fn main() {
let result = count_words("rust memory safety and speed");
println!("{:?}", result);
}