diff options
Diffstat (limited to 'library/stdarch/crates/intrinsic-test/src/common/format.rs')
| -rw-r--r-- | library/stdarch/crates/intrinsic-test/src/common/format.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/library/stdarch/crates/intrinsic-test/src/common/format.rs b/library/stdarch/crates/intrinsic-test/src/common/format.rs new file mode 100644 index 00000000000..9ee331d7f7a --- /dev/null +++ b/library/stdarch/crates/intrinsic-test/src/common/format.rs @@ -0,0 +1,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(()) + } +} |
