pub_just/show_whitespace.rs
1use super::*;
2
3/// String wrapper that uses nonblank characters to display spaces and tabs
4pub struct ShowWhitespace<'str>(pub &'str str);
5
6impl<'str> Display for ShowWhitespace<'str> {
7 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
8 for c in self.0.chars() {
9 match c {
10 '\t' => write!(f, "␉")?,
11 ' ' => write!(f, "␠")?,
12 _ => write!(f, "{c}")?,
13 };
14 }
15
16 Ok(())
17 }
18}