2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2019-10-09 01:40:40 -07:00
|
|
|
|
2020-02-14 04:49:25 -08:00
|
|
|
/// String wrapper that uses nonblank characters to display spaces and tabs
|
2019-10-09 01:40:40 -07:00
|
|
|
pub struct ShowWhitespace<'str>(pub &'str str);
|
|
|
|
|
|
|
|
impl<'str> Display for ShowWhitespace<'str> {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
|
|
for c in self.0.chars() {
|
|
|
|
match c {
|
|
|
|
'\t' => write!(f, "␉")?,
|
|
|
|
' ' => write!(f, "␠")?,
|
2022-12-15 16:53:21 -08:00
|
|
|
_ => write!(f, "{c}")?,
|
2019-10-09 01:40:40 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|