From 8e514a90420d2d499fbf35f2e51ba7437ab235be Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 23 Jun 2024 16:16:58 -0700 Subject: make DisplaySinkValidator actually usable outside this crate --- src/testkit/display.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/testkit/display.rs') 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(()) -- cgit v1.1