And this lecture we're going to start talking about utility traits.
And utility traits are a grab bag of various traits from the standard library that have enough of an
impact on the way rest is written, that it's important for us to be familiar with them.
So the first one that we're going to look at is the drop tray.
And we've heard the word drop being used kind of throughout this course.
And when we talk about dropping and rust, we are referring to the freeing of the resources the value
is using.
Drops occur in a number of situations, such as when a variable goes out of scope at the end of an expression,
removing elements from a vector and the list goes on and on.
Luckily Rust almost always will handle this for us, but it is an important trait to know.
So let's look at how we can use it.
So we'll piggyback off of our struct course and what we'll do is we'll implement drop for course.
And then we're going to have the drop function, which is going to contain a mutable reference to the
self.
And then in here, just to demonstrate how it works, we'll say we're dropping.
And then we'll just say self dot art author.
So now when we come down here, we can manually call this ourselves and we can say drop course one because
that is what used our course.
Struct and now if we run it, we'll see that it says dropping Tyler.
So we manually call this drop trait and we manually freed up our resources, but we could delete this
line.
And rerun this and see that it still calls dropping.
Tyler because here is where course one went out of scope and so it called our implementation of drop
which.
We told to hey print out dropping Tyler and then free up the resources so.
That is what the drop trait is.
And now let's go look at a couple more.
Starting off with what the clone trade is.