Rust Programming Exercises: Reverse Linked List

preview_player
Показать описание
In this video we will be implementing the reverse linked list exercise in Rust. We make use of the recursive data structure for Nodes, Options, and the Box smart pointer to handle pointers to the next nodes in the list. For this to work, we created a push and pop operation. As well, we also managed to learn about the Into trait to convert our list into a vector of numbers, implemented the actual reverse function and even cleaned up our structure with the Drop trait.

↠ References:

Cheers! 🍻

🦀 #rust #rustlang #rustprogramming #exercises #leetcode #programming
Рекомендации по теме
Комментарии
Автор

This is great Thomas, thanks!  🙏

Minor enhancement - noticed that you don't need to define current_next in reverse().
fn reverse(&mut self) {
let mut current_head = self.head.take();
while let Some(mut current_node) = current_head {
current_head = current_node.next.take();
current_node.next = self.head.take();
self.head = Some(current_node);
}
}

v.agarwal
Автор

Great vid!, and I was wondering what software you use for drawing at 1:49?

omarmagdy
Автор

Nice video! Btw, what's the font you use in vim?

gabrielpacheco