remove_dir_all/_impl/
path_components.rs

1use std::{fmt::Display, path::Path};
2
3/// Print a path that is broken into segments.
4// explicitly typed to avoid type recursion. 'a is the smallest lifetime present
5// : that of the child.
6pub(crate) enum PathComponents<'a> {
7    Path(&'a Path),
8    Component(&'a PathComponents<'a>, &'a Path),
9}
10
11impl<'p> Display for PathComponents<'p> {
12    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13        match self {
14            PathComponents::Path(p) => p.display().fmt(f),
15            PathComponents::Component(p, c) => {
16                p.fmt(f)?;
17                f.write_str("/")?;
18                c.display().fmt(f)
19            }
20        }
21    }
22}