From the course: Rust for Data Engineering
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Storing unique fruits using HashSet in Rust - Rust Tutorial
From the course: Rust for Data Engineering
Storing unique fruits using HashSet in Rust
- [Instructor] All right, in this video, I have a simple Rust program that generates a list of 100 random fruits and calculates the number of unique fruits we end up with. So let's go ahead and take a look at the very beginning here. One of the key takeaways, as well as I'm using the rand external crate here to help me out. And in particular, the sequence slice, random and thread, rng here, are doing a lot of the heavy lifting, because they'll generate a random choice from a list of fruits. And a lot of times, this is a great way to generate random choices, is in this case, this is a vector. And I'm going to feed it into the random selections from the rand crate. Now, we're going to use a hash set from the standard library collection as well. So that's another thing to pay attention to. And one of the key properties of a hash set is that it will only store unique elements. So this is perfect for this kind of use…
Contents
-
-
-
-
Analyzing UFC fighter network using graph centrality in Rust4m 12s
-
(Locked)
Storing unique fruits using HashSet in Rust3m 18s
-
(Locked)
Maintaining sorted and unique fruits using BTreeSet in Rust2m 35s
-
(Locked)
Creating a fig-priority fruit salad using BinaryHeap in Rust2m 42s
-
(Locked)
PageRank algorithm for sports data4m 12s
-
(Locked)
Showing shortest path with Dijkstra3m 27s
-
(Locked)
Detecting strongly connected components: A deep dive into Kosaraju's algorithm4m 14s
-
(Locked)
Simple charting of data structures in Rust2m 26s
-
-
-
-
-
-
-
-
-
-