use core::fmt;
use crate::node_data::{NodesDataLend, NodesDataLendGat};
use super::*;
#[derive(Clone)]
struct FmtDebugList<Iter> {
iter: Iter,
}
impl<'head, Nodes, Index> ListAccessor<'head, Nodes, Index>
where
Nodes: NodesLink<Index> + NodesDataLend<Index>,
Index: PartialEq + Clone,
{
#[inline]
pub fn debug(&self) -> impl fmt::Debug + Clone
where
for<'a> <Nodes as NodesDataLendGat<'a, Index>>::Data: fmt::Debug,
Index: fmt::Debug,
{
FmtDebugList { iter: self.iter() }
}
#[inline]
pub fn debug_indices(&self) -> impl fmt::Debug + Clone
where
Index: fmt::Debug,
{
FmtDebugList {
iter: self.indices(),
}
}
#[inline]
pub fn debug_values(&self) -> impl fmt::Debug + Clone
where
for<'a> <Nodes as NodesDataLendGat<'a, Index>>::Data: fmt::Debug,
{
FmtDebugList {
iter: self.values(),
}
}
}
impl<Iter> fmt::Debug for FmtDebugList<Iter>
where
Iter: Iterator<Item: fmt::Debug> + Clone,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list().entries(self.iter.clone()).finish()
}
}