Rust HashMap and HashSet Collection Types 🦀

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

The Rust standard library provides a couple of useful constructs called the HashMap and HashSet. These types are exposed in the "collections" module with the "std" crate. You don't need to install anything beyond the Rust toolchain in order to have access to these data types.
HashMaps are also known as "dictionary" or "hashtable" types in other programming languages. HashMaps are sometimes referred to as "associative arrays" as well. Each entry in a HashMap must have a unique key, and any value. The data types for HashMap keys and values can be almost anything, even user-defined structs, thanks to Rust generics, as long as they implement the necessary Traits (Eq, Hash, PartialEq). Keep in mind that Traits can't be used as keys, however.
HashSets allow you to create a "set" (array) of unique values. HashSets are also a generic type, which means they can contain any data type that you wish. A given value cannot appear more than once in a HashSet, making them useful constructs for any situation where you need to avoid accidental duplicate values.
🤯 Rust Programming Playlist 🦀 • Rust Programming Tutor...
📖 Rust HashMap docs ➡️ doc.rust-lang.org/stable/std/...
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

Пікірлер: 8

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

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

  • @fabricehategekimana5350
    @fabricehategekimana53507 ай бұрын

    I am very grateful for the work you do! The quality and resources are great. God bless you

  • @TrevorSullivan

    @TrevorSullivan

    7 ай бұрын

    You are very kind. Thank you so much for your support. God bless you and keep you as well. ✝️

  • @shailendrajadhav8603
    @shailendrajadhav860310 ай бұрын

    Thank you for creating this playlist; these are easy to understand examples. Would you consider creating a real world application using all these concepts?

  • @TrevorSullivan

    @TrevorSullivan

    10 ай бұрын

    Thank you! Yes, I would certainly consider creating a full application. I'm focusing on the core concepts of Rust for now, but once we cover most of those, I'll create some practical Rust applications! Rust on! 🦀🦀

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

    Hi Sullivan, when removing the "AAPL".to_string() from the stock list, why a & is needed ?🤔

  • @TrevorSullivan

    @TrevorSullivan

    9 ай бұрын

    That's an excellent question. I believe the simplest answer is that the .remove() method signature requires a borrow of the underlying key type. In this case, my HashMap key was of type String, so in order to satisfy the method signature, I had to use &String. That is essentially what the documentation says here doc.rust-lang.org/stable/std/collections/struct.HashMap.html#method.remove

Келесі