orx_linked_list/list/common_traits/
debug.rs1use crate::{DoublyIterable, List, Singly, SinglyIterable, variant::Doubly};
2use core::fmt::Debug;
3use orx_pinned_vec::PinnedVec;
4use orx_selfref_col::{MemoryPolicy, Node};
5
6impl<T: Debug, M, P> Debug for List<Singly<T>, M, P>
7where
8 M: MemoryPolicy<Singly<T>>,
9 P: PinnedVec<Node<Singly<T>>>,
10 List<Singly<T>, M, P>: Default,
11{
12 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
13 write!(f, "[")?;
14
15 let mut iter = self.iter();
16 if let Some(first) = iter.next() {
17 write!(f, "{:?}", first)?;
18 for x in iter {
19 write!(f, " -> {:?}", x)?;
20 }
21 }
22
23 write!(f, "]")
24 }
25}
26
27impl<T: Debug, M, P> Debug for List<Doubly<T>, M, P>
28where
29 M: MemoryPolicy<Doubly<T>>,
30 P: PinnedVec<Node<Doubly<T>>>,
31 List<Doubly<T>, M, P>: Default,
32{
33 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
34 write!(f, "[")?;
35
36 let mut iter = self.iter();
37 if let Some(first) = iter.next() {
38 write!(f, "{:?}", first)?;
39 for x in iter {
40 write!(f, " <-> {:?}", x)?;
41 }
42 }
43
44 write!(f, "]")
45 }
46}