-
Notifications
You must be signed in to change notification settings - Fork 296
Open
Description
I wasn't familiar with the concept of tail recursion so didn't understand Section 2.7 fully, but this is what I came up with for implementing the Drop trait:
impl Drop for List {
fn drop(&mut self) {
while let Link::More(node) = mem::replace(&mut self.head, Link::Empty) {
self.head = node.next;
}
}
}Q: Is it logically equivalent to the code in the book? If so, this is more elegant imo.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels