Cache Lines
100 points
Cache needs to remember the split-out lines of `raw`. The code below does not compile. Redesign the struct and implement `new` and `lines` so `lines` returns the split lines, in order, split on '\n'.
Required signature
pub struct Cache { /* your fields */ } impl Cache { pub fn new(raw: String) -> Self; pub fn lines(&self) -> Vec<&str>; }
Visible tests
-
splits_into_lines#[test] fn splits_into_lines() { let cache = Cache::new("first\nsecond\nthird".to_string()); assert_eq!(cache.lines(), vec!["first", "second", "third"]); }
Your solution
Log in to submit a solution.