# Exercise: String Manipulator Tool **Concepts practiced:** String vs &str, ownership/borrowing, Vec operations, pattern matching **Objective:** Build a CLI tool that performs various string operations ## Requirements: - Create a `StringTool` struct that holds a collection of strings - Implement methods: - `new()` - creates empty tool - `add_string(&mut self, s: String)` - adds string to collection - `longest(&self) -> Option<&str>` - returns longest string (or None if empty) - `contains_word(&self, word: &str) -> Vec<&str>` - returns strings containing the word - `to_uppercase_all(&mut self)` - converts all strings to uppercase in-place ## Success criteria: - Code compiles without warnings - Test with: adding "hello", "world", "rust programming" - `longest()` should return "rust programming" - `contains_word("o")` should return vec!["hello", "world", "rust programming"] - After `to_uppercase_all()`, all strings should be uppercase ## Stretch goal: Add a method `word_count(&self) -> HashMap` that counts total occurrences of each word across all strings ## Getting Started: 1. `cd exercises && cargo new string-manipulator` 2. Focus on ownership: when do you need `String` vs `&str`? 3. Think about borrowing: methods that read vs modify Expected time: 45-60 minutes