Hey there! Hopefully, you've enjoyed this video! I am open to any feedback :) FYI: This would be the more enhanced version for the `get_words_in_range` function: ```rust fn get_words_in_range(&self, start: usize, end: usize) -> Vec { self.text .split_whitespace() .skip(start) .take(end - start) .collect() } ```
You should also have shown the inclusive syntax for slicing which uses ..= so that the end index is included. For example, let v = vec![0, 1, 2, 3, 4]; let s = &v[1..=3]; and you get [1, 2, 3]. I don't understand their rationale for this design choice since I think that .. should be an inclusive range, but I assume it's because they didn't think of using other symbols. For my own language, I opted to use .. for inclusive slicing, : for start and length slicing, and commas for selection. I don't know if it's too late to get someone working on Rust to incorporate this idea, but an example of its usage would be: v := [1, 2, 3, 4, 5, 6], inclusive_slice = v[1..3], start_plus_length = v[1:2], selections = v[1,3,5]; then the results would be [2,3,4], [2,3], [2,4,6].
Hey there! Hopefully, you've enjoyed this video! I am open to any feedback :)
FYI: This would be the more enhanced version for the `get_words_in_range` function:
```rust
fn get_words_in_range(&self, start: usize, end: usize) -> Vec {
self.text
.split_whitespace()
.skip(start)
.take(end - start)
.collect()
}
```
man all your vids about rust is gold i wish there is more of it
Thank you so much! There are a few of them, but I'll definitely focus some of my time on Rust-related videos :)
You should also have shown the inclusive syntax for slicing which uses ..= so that the end index is included. For example, let v = vec![0, 1, 2, 3, 4]; let s = &v[1..=3]; and you get [1, 2, 3]. I don't understand their rationale for this design choice since I think that .. should be an inclusive range, but I assume it's because they didn't think of using other symbols. For my own language, I opted to use .. for inclusive slicing, : for start and length slicing, and commas for selection. I don't know if it's too late to get someone working on Rust to incorporate this idea, but an example of its usage would be: v := [1, 2, 3, 4, 5, 6], inclusive_slice = v[1..3], start_plus_length = v[1:2], selections = v[1,3,5]; then the results would be [2,3,4], [2,3], [2,4,6].
Pretty Interesting, I was kinda confused about Rust slices, but this video really helped ^^.
So awesome to hear that it helped! :)
what font are you using?
The font is called Monaspace :)
what is the name of the font you are using, I love your videos by the way 💥
The font is called Monaspace :) Thank you for watching! :)