dsa/data_structures/
node.rs

1/// A node in a data structure.
2///
3/// This structure represents a single node that stores a value of type `T`
4/// and optionally links to the next node in the list.
5pub struct Node<T> {
6    /// The value stored in this node.
7    pub value: T,
8
9    /// The next node in the structure
10    /// or `None` if this is the last node.
11    pub next: Option<Box<Node<T>>>,
12}
13
14impl<T> Node<T> {
15    /// Creates a new node with the given value.
16    pub fn new(value: T, next: Option<Box<Node<T>>>) -> Self {
17        Node {
18            value,
19            next,
20        }
21    }
22}