standard_lib/collections/linked/cursor/
state.rs

1use derive_more::IsVariant;
2
3/// An enum to represent the state of a [`Cursor`](super::Cursor).
4#[derive(Debug, PartialEq, Eq, IsVariant)]
5pub enum State<'a, T> {
6    /// The cursor holds an empty list and therefore doesn't point anywhere.
7    Empty,
8    /// The cursor is pointing to the 'ghost' element before the start of a list.
9    Head,
10    /// The cursor is pointing to the 'ghost' element after the end of a list.
11    Tail,
12    /// The cursor is pointing to a Node within the list, containing the borrowed value.
13    Node(&'a T),
14}
15
16/// An enum to represent the state of a [`Cursor`](super::Cursor) while allowing for mutation.
17#[derive(Debug, PartialEq, Eq, IsVariant)]
18pub enum StateMut<'a, T> {
19    /// The cursor holds an empty list and therefore doesn't point anywhere.
20    Empty,
21    /// The cursor is pointing to the 'ghost' element before the start of a list.
22    Head,
23    /// The cursor is pointing to the 'ghost' element after the end of a list.
24    Tail,
25    /// The cursor is pointing to a Node within the list, containing the mutably borrowed value.
26    Node(&'a mut T),
27}