pub struct DetectorGuard { /* private fields */ }Expand description
RAII guard that calls reset_detectors when dropped.
Install at the start of a test to guarantee the overrides are torn down on normal exit and on panic-induced unwind, so a failing assertion doesn’t leak state into the next serial test.
use standout_render::environment::{DetectorGuard, set_terminal_width_detector, detect_terminal_width};
let _guard = DetectorGuard::new();
set_terminal_width_detector(|| Some(80));
assert_eq!(detect_terminal_width(), Some(80));
// `_guard` resets everything when it goes out of scope.Implementations§
Source§impl DetectorGuard
impl DetectorGuard
Trait Implementations§
Source§impl Default for DetectorGuard
impl Default for DetectorGuard
Auto Trait Implementations§
impl Freeze for DetectorGuard
impl RefUnwindSafe for DetectorGuard
impl Send for DetectorGuard
impl Sync for DetectorGuard
impl Unpin for DetectorGuard
impl UnsafeUnpin for DetectorGuard
impl UnwindSafe for DetectorGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more