Created
April 7, 2021 10:31
-
-
Save frgomes/46d60e1da1d76df878323467a9930a8e to your computer and use it in GitHub Desktop.
Rust - LinkedList and DoubleLinkedList
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod LinkedList { | |
type Link<T> = Option<Box<Node<T>>>; | |
struct Node<T> { | |
value: T, | |
next: Link<T>, | |
} | |
} | |
mod DoubleLinkedList { | |
use core::cell::RefCell; | |
use std::rc::Rc; | |
type Link<T> = Option<Rc<RefCell<Node<T>>>>; | |
struct Node<T> { | |
value: T, | |
prev: Link<T>, | |
next: Link<T>, | |
} | |
} | |
fn main() { | |
println!("It compiles!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment