Files
rust/library/stdarch/crates/intrinsic-test/src/format.rs
Jacob Bramley 211a00769c Improve intrinsic-test output formatting.
This change is simple, but makes the generated tests much easier to
follow (and debug).
2023-11-17 23:49:21 -08:00

29 lines
608 B
Rust

//! 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)]
pub struct Indentation(u32);
impl std::default::Default for Indentation {
fn default() -> Self {
Self(0)
}
}
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(())
}
}