1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! A doubly linked list with a cursor based api.
//! *it's also an iterator!*
//!
//! `O(1)` pretty much everything (at the cursor).
//!
//! ## Example
//!
//! ```rust
//! use iterlist::IterList;
//!
//! let mut list = IterList::new();
//!
//! list.push_prev(-1);
//! list.push_next(1);
//! list.push_next(2);
//! list.push_next(3);
//!
//! assert_eq!(format!("{:?}", list), "[-1, 1, 2, 3]");
//!
//! list.move_to(2);
//! assert_eq!(list.current(), Some(&2));
//!
//! list.move_by(-2);
//! assert_eq!(list.index(), 0);
//!
//! let mut cursor = list.as_cursor();
//! assert_eq!(cursor.next(), Some(&-1));
//! assert_eq!(cursor.next(), Some(&1));
//!
//! assert_eq!(list.get(1), Some(&1));
//!
//! list.move_by(2);
//! let (elem, _) = list.consume_forward().unwrap();
//! assert_eq!(elem, 2);
//!
//! assert_eq!(format!("{:?}", list), "[-1, 1, 3]");
//!
//! let num = list.fold(0, |acc, elem| acc + elem);
//!
//! assert_eq!(num, 3);
//! ```
pub use ;