Struct loop_guard::LoopGuard
source · [−]Expand description
Utility for preventing infinite loops
Use as a guard rail inside a loop or while block
Meant to be used as a development dependency
Fields
max_ticks: i32count: i32Implementations
sourceimpl LoopGuard
impl LoopGuard
sourcepub fn new(max: i32) -> LoopGuard
pub fn new(max: i32) -> LoopGuard
Create a new LoopGuard
Make sure to create the LoopGuard instance outside the loop block
Arguments
max_ticks- The limit of how many times a loop should run
ⓘ
use loop_guard::LoopGuard;
let mut guard = LoopGuard::new(10);
loop {
guard.protect() // This panic after 10 loops
}Auto Trait Implementations
impl RefUnwindSafe for LoopGuard
impl Send for LoopGuard
impl Sync for LoopGuard
impl Unpin for LoopGuard
impl UnwindSafe for LoopGuard
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more