diff --git a/README.md b/README.md index 82862f8..50dc406 100644 --- a/README.md +++ b/README.md @@ -4895,7 +4895,7 @@ This prints `["June", "July"]`. -`.filter_map()`. This is called `filter_map()` because it does `.filter()` and `.map()`. The closure must return an `Option`, and then `filter.map()` takes the value out of each `Option` if it is `Some`. So for example if you were to `.filter_map()` a `vec![Some(9), None, Some(3)]`, it would return `[2, 3]`. +`.filter_map()`. This is called `filter_map()` because it does `.filter()` and `.map()`. The closure must return an `Option`, and then `filter.map()` takes the value out of each `Option` if it is `Some`. So for example if you were to `.filter_map()` a `vec![Some(2), None, Some(3)]`, it would return `[2, 3]`. We will write an example with a `Company` struct. Each company has a `name` so that field is `String`, but the CEO might have recently quit. So the `ceo` field is `Some`. We will `.filter_map()` over some companies to just keep the CEO names. @@ -5177,7 +5177,7 @@ Some(5) Some(6) ``` -We were right: there is oone `Some(5)` and then the 1000 `Some(6)` start. So we can write this: +We were right: there is one `Some(5)` and then the 1000 `Some(6)` start. So we can write this: ```rust fn main() { @@ -5264,8 +5264,8 @@ Something similar can be done with a range that doesn't have an ending. If you w ```rust fn main() { - let ten_chars = ('a'..).into_iter().take(10).collect::>(); - let skip_then_ten_chars = ('a'..).into_iter().skip(1300).take(10).collect::>(); + let ten_chars = ('a'..).take(10).collect::>(); + let skip_then_ten_chars = ('a'..).skip(1300).take(10).collect::>(); println!("{:?}", ten_chars); println!("{:?}", skip_then_ten_chars);