Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rust - LinkedList and DoubleLinkedList
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