Use the Rust Vec Type for Dynamically Expanding Arrays 🦀

Ғылым және технология

In this video, we'll explore the Rust Vec type in the std::vec module. Vec is useful as a dynamically-sized array, and provides many helper methods for adding items, removing items, joining multiple Vec objects together, reserve additional system memory, and more!
There's a vec! macro in Rust that simplifies instantiating a Vec. You can use the .push() method to add items to a mutable Vec. The .append() method on Vec allows you to join another Vec, with the same underlying data type, to itself. The .remove() method will delete an item from a Vec at a specific index. The .reserve() method can be used to reserve extra system memory if a Vec's size will be increased. You can also use .len() and .capacity() methods to monitor the number of items, and reserved size, for a given Vec.
🤯 Rust Programming Playlist 🦀 • Rust Programming Tutor...
📖 Rust Vec Type Reference: doc.rust-lang.org/std/vec/str...
📖 Using Rust Vec Type: doc.rust-lang.org/book/ch08-0...
Visual Studio Code ➡️ code.visualstudio.com
Rust Website ➡️ rust-lang.org
Rustup Installer ➡️ rustup.rs
Rust Docs ➡️ doc.rust-lang.org/book
Please follow me on these other social channels!
➡️ trevorsullivan.net
➡️ github.com/pcgeek86
➡️ / pcgeek86
➡️ / trevorsullivan
➡️ / trevorsoftware
➡️ tiktok.com/pcgeek86
All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names,trademarks and brands does not imply endorsement.
#rustlang #rust #rustdev #opensource #software #linux #devops #programming #rusty #dev #coding #codinglife #code #coder #ubuntu #ubuntulinux #appdev #developer

Пікірлер: 21

  • @TrevorSullivan
    @TrevorSullivan9 ай бұрын

    Check out the full Rust playlist for more Rust programming videos! 🦀 ➡➡➡➡ kzread.info/head/PLDbRgZ0OOEpUkWDGqp91ODn0dk7LPBAUL

  • @restauradorcaseiro
    @restauradorcaseiro19 күн бұрын

    A playlist about the stabby macro = ❤❤

  • @MH-bw9lh
    @MH-bw9lh10 ай бұрын

    Feel like every day to have a lesson, very nice.

  • @mssafy2592
    @mssafy259225 күн бұрын

    man , thank you so much 🥺✨

  • @hsthast7183
    @hsthast718310 ай бұрын

    Really enjoying the series. keep it up 👍

  • @maguilecutty
    @maguilecutty6 ай бұрын

    How does this guy have such little traction? He’s the best if ur a beginner/intermediate like me!!

  • @bicube7529
    @bicube75297 ай бұрын

    yeah, i needed the reminder at the beginning of the video, i still wasnt subscribed . i watched like, 2 entire playlists about rust, but they go to fast, i am a programmer, but im a slow one, the fact that you really go into the topics, i feel like i'm exploring the stuff, testing and seeing what happens and then great explanations. great work, keep up, let's grow this community

  • @TrevorSullivan

    @TrevorSullivan

    7 ай бұрын

    You rock! Thanks so much for your support. I'm so happy that you're learning Rust along with me! It's quite the process.

  • @ERAYKAAN850
    @ERAYKAAN8509 ай бұрын

    nice video!

  • @TrevorSullivan

    @TrevorSullivan

    9 ай бұрын

    Thank you! ♥️ I have more coming. One is processing now.

  • @subhamprasad1373
    @subhamprasad13736 ай бұрын

    Make video on macros....in depth video

  • @Hellbending
    @Hellbending5 ай бұрын

    I really love your videos because you go into a reasonable amount of detail with what’s happening and I just had a couple questions about these videos, and I guess like… ‘who these videos are really aimed at’ which might sound a little strange but there’s a couple of things that you do that don’t quite make sense to me given the videos are aimed at very early learning. They are obviously aimed at beginners and potentially even people brand-new to programming as a whole and often times you do some things that seem rather counterintuitive to general good programming practice, but I’m not understanding why you do them, i’m only at 13:30 of this particular video but I’ve seen it happen in a couple of your other videos where you prefer to duplicate code over using something that’s already there (and you don’t go back to use it/change it for further examples etc. so it doesn’t serve a real purpose of duplicating it) and by this point in the video you create a second loop of 0 to 100 when we already have a loop that exists. The other major thing there’s things that come up like using swap_remove instead of remove in the tooltip that mentions if you’re removing an item from the first index (which we’re doing here in the example) to not use removed because it has to shift everything within the Vec - and says it’s is incredibly bad when it comes to performance. I think acknowledging the tooltip for the general/beginner viewers or even just giving a bit of a nod towards those kind of things when they pop up just to help newbies understand it exists and there’s very much reasons to not use specific methods etc. Sort of like, they need to learn the remove method, but it might not be perfect in a situation like this, where we’re operating on the very first index (or in even larger Vec or array) I’m not meaning to bring this to you as like a point of contention or anything wrong I just think it might be that extra little bit that might really put you in a couple peoples recommendation spotlight of getting friends to come watch your content ya know, things like that. Much love brother ❤

  • @TrevorSullivan

    @TrevorSullivan

    5 ай бұрын

    Hey Blake, thank you for sharing all your thoughts in so much detail! I am still learning this language, and I'm just sharing knowledge as I progressively learn it. That's probably why you see me occasionally miss helper methods, that make life a little bit easier than the way I do it (ie. swap_remove). I'm not entirely sure, but I *think* the reason that you see me duplicating code, is to section it off so that it's still a working example. If someone is following along, and I modify the code that we talked about over the last couple of minutes, they might lose perspective. Does that make sense? In more recent videos, I know that I have started sectioning code off into separate functions and structs. That helps keep things more organized as we progressively add new topics to the discussion. I appreciate your support! I'm still learning Rust today, however I've been posting on my company's blog and KZread channel. You can check it out at stratusgrid.com/blog God bless you! ❤️ Rust on! 🦀

  • @pipi_delina
    @pipi_delina10 ай бұрын

    This course is very informative. can you build an API with it in a simple project with auth and postgres db.

  • @TrevorSullivan

    @TrevorSullivan

    10 ай бұрын

    For sure! I will get to some app creation after we cover most of the Rust fundamentals! Great idea! 💡 Rust on!! 🦀 Thank you for your kind comment!

  • @aintnochange
    @aintnochange6 ай бұрын

    Hi, thank you for another awesome video! Just a question about the ranges on 13:30, can I just use &my_ints[0..=5] instead? I'm kinda confused because it works similar for me and I cant see any difference

  • @TrevorSullivan

    @TrevorSullivan

    6 ай бұрын

    Good question! It looks like the difference is that you are using a reference to the array, which I believe gives you a slice. That looks a lot more concise than what I did in the video! Nice find! Thanks for your support!

  • @pipi_delina
    @pipi_delina9 ай бұрын

    How does one do test in rust. Do you have plans for such? Like TDD Rust

  • @TrevorSullivan

    @TrevorSullivan

    9 ай бұрын

    Another great question! Yes, I'll get to Rust testing eventually! I'm trying to start with the language fundamentals, using as few dependencies as possible, but using the built-in test annotations. doc.rust-lang.org/book/ch11-01-writing-tests.html

  • @sdlfljdfkl
    @sdlfljdfkl4 ай бұрын

    In 36:30, it should be possible to just have |e: &Car| e.manufacturer == "Porsche", that is already the sought boolean!

  • @TrevorSullivan

    @TrevorSullivan

    4 ай бұрын

    That's a lot cleaner! Thanks for sharing.

Келесі