about summary refs log tree commit diff
path: root/library/stdarch/crates/intrinsic-test/src/common/indentation.rs
blob: 9ee331d7f7a3f79594769211a26fc11ce8170841 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//! Basic code formatting tools.
//!
//! We don't need perfect formatting for the generated tests, but simple indentation can make
//! debugging a lot easier.

#[derive(Copy, Clone, Debug, Default)]
pub struct Indentation(u32);

impl Indentation {
    pub fn nested(self) -> Self {
        Self(self.0 + 1)
    }
}

impl std::fmt::Display for Indentation {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        for _ in 0..self.0 {
            write!(f, "    ")?;
        }
        Ok(())
    }
}