Using slices in Rust is pretty powerful!

Поделиться
HTML-код
  • Опубликовано: 20 янв 2025

Комментарии • 10

  • @FloWoelki
    @FloWoelki  2 месяца назад +4

    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()
    }
    ```

  • @lMINERl
    @lMINERl 2 месяца назад

    man all your vids about rust is gold i wish there is more of it

    • @FloWoelki
      @FloWoelki  2 месяца назад +1

      Thank you so much! There are a few of them, but I'll definitely focus some of my time on Rust-related videos :)

  • @anon_y_mousse
    @anon_y_mousse 2 месяца назад

    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].

  • @sponkurtus2597
    @sponkurtus2597 2 месяца назад

    Pretty Interesting, I was kinda confused about Rust slices, but this video really helped ^^.

    • @FloWoelki
      @FloWoelki  2 месяца назад

      So awesome to hear that it helped! :)

  • @qussaigamer553
    @qussaigamer553 2 месяца назад +1

    what font are you using?

    • @FloWoelki
      @FloWoelki  2 месяца назад +1

      The font is called Monaspace :)

  • @chinxeleer
    @chinxeleer 2 месяца назад

    what is the name of the font you are using, I love your videos by the way 💥

    • @FloWoelki
      @FloWoelki  2 месяца назад

      The font is called Monaspace :) Thank you for watching! :)