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.

Creating a fig-priority fruit salad using BinaryHeap in Rust

Creating a fig-priority fruit salad using BinaryHeap in Rust - Rust Tutorial

From the course: Rust for Data Engineering

Creating a fig-priority fruit salad using BinaryHeap in Rust

- [Instructor] All right, in this video I'm going to make a Rust program that creates a fruit salad, but it has a twist here in that I'm going to assign the fruit fig, which is one of my favorite fruits, the priority. And this program uses the Binary Heap to accomplish this. And the Rust Standard Library is able to actually build this for us, which is nice. Binary Heap comes from standard library collections. And the first thing that we're going to take a look at is there's an enum here, which is a fig, and other. And then in this particular scenario here, I'm going to define figs as the highest priority by implementing Ord. So I say implement Ord. So basically make the order here. And I'm going to say that, basically, figs here are going to be at the top and then other fruits are going to be at the bottom, here. And then I also have partial order as well. And then finally, I get into the generation of the fruit salad. So…

Contents