diff options
author | iximeow <me@iximeow.net> | 2024-06-23 16:16:58 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2024-06-23 16:16:58 -0700 |
commit | 8e514a90420d2d499fbf35f2e51ba7437ab235be (patch) | |
tree | 3db027e2240fe9da14dccdd354dc9a3bce256ddf /src/testkit/display.rs | |
parent | 288f0b64a03fe99a6765298a181dfb4ae41049b5 (diff) |
make DisplaySinkValidator actually usable outside this crate
Diffstat (limited to 'src/testkit/display.rs')
-rw-r--r-- | src/testkit/display.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/testkit/display.rs b/src/testkit/display.rs index a745b5c..3cffd49 100644 --- a/src/testkit/display.rs +++ b/src/testkit/display.rs @@ -20,6 +20,20 @@ pub struct DisplaySinkValidator { spans: alloc::vec::Vec<&'static str>, } +impl DisplaySinkValidator { + pub fn new() -> Self { + Self { spans: alloc::vec::Vec::new() } + } +} + +impl core::ops::Drop for DisplaySinkValidator { + fn drop(&mut self) { + if self.spans.len() != 0 { + panic!("DisplaySinkValidator dropped with open spans"); + } + } +} + impl fmt::Write for DisplaySinkValidator { fn write_str(&mut self, _s: &str) -> Result<(), fmt::Error> { Ok(()) |