parallel_disk_usage/visualizer/
display.rs

1use super::{Direction::*, Visualizer};
2use crate::size;
3use std::fmt::{Display, Error, Formatter};
4
5impl<'a, Name, Size> Display for Visualizer<'a, Name, Size>
6where
7    Name: Display,
8    Size: size::Size + Into<u64>,
9{
10    /// Create the ASCII chart.
11    fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error> {
12        let write = |line: &String| writeln!(formatter, "{line}");
13        match self.direction {
14            BottomUp => self.rows().iter().rev().try_for_each(write),
15            TopDown => self.rows().iter().try_for_each(write),
16        }
17    }
18}