Rust Programming Exercises: Double Linked List

preview_player
Показать описание
In this video we implement a Double Linked List in Rust by working with the Weak Smart Pointer and Reference Counters. Similar to several other videos I implemented on the binary tree algorithms, in order to share pointers we make use of the Reference Counter to store a reference to the head and tail of the linked list. The double linked list allows us to point to a previous value in the list as well. However, in order to point to the previous item in the list we must avoid reference cycles and memory leaks by making use of Weak Smart Pointers. We learn about how to properly downgrade and upgrade a weak reference in order to work with the underlying data and I discuss the use of null pointer optimizations and the drop trait to properly clean up our list.

↠ Other Videos to Watch

↠ References:

Cheers! 🍻

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

Thank you so much for this video, it helped me learned a lot more about Rust than I have ever expected
But I got to say programming a linked list in Rust in this safe version is way harder than other programming languages that I've used, C++ for example is so quick and easy, but I'm going all in for the safetyness Rust provides

vintagewander
Автор

Thanks very much for this one. In the process of implementing a LRU cache and wasn't 100% on double linked lists in Rust... SAVE!!

leonardosimmons
Автор

Thank you. Demystifying such topics are really needed.

ostadomid
Автор

I only wish you explained *WHY* you used RefCell and Rc, how you knew you needed them, etc.

Stumashedpotatoes
Автор

Hi Thomas, do you have a video where you show us how you setup your IDE for Rust? Please a tutorial for VIM + Rust.

SaifAli
Автор

I don't think there is any null pointer optimization for Rc or Weak. It lists right there in the documentation you pointed to what types have NPO and neither are listed.

garaleth
Автор

Is there no way to create a helper push_helper(self, value, a, b) and then push_front(self, value) calls push_helper(self, value, head, tail) and push_back(self, value) calls push_helper(self, value, tail, head)?

beyondmeaning