pub struct FnStop<F> { /* private fields */ }Expand description
A Stop implementation backed by a closure.
The closure should return true when the operation should stop.
§Example
use almost_enough::{FnStop, Stop};
use core::sync::atomic::{AtomicBool, Ordering};
let flag = AtomicBool::new(false);
let stop = FnStop::new(|| flag.load(Ordering::Relaxed));
assert!(!stop.should_stop());
flag.store(true, Ordering::Relaxed);
assert!(stop.should_stop());Implementations§
Trait Implementations§
impl<F: Copy> Copy for FnStop<F>
Auto Trait Implementations§
impl<F> Freeze for FnStop<F>where
F: Freeze,
impl<F> RefUnwindSafe for FnStop<F>where
F: RefUnwindSafe,
impl<F> Send for FnStop<F>where
F: Send,
impl<F> Sync for FnStop<F>where
F: Sync,
impl<F> Unpin for FnStop<F>where
F: Unpin,
impl<F> UnwindSafe for FnStop<F>where
F: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> StopExt for Twhere
T: Stop,
impl<T> StopExt for Twhere
T: Stop,
Source§impl<T> TimeoutExt for Twhere
T: Stop,
impl<T> TimeoutExt for Twhere
T: Stop,
Source§fn with_timeout(self, duration: Duration) -> WithTimeout<Self>
fn with_timeout(self, duration: Duration) -> WithTimeout<Self>
Add a timeout to this stop. Read more
Source§fn with_deadline(self, deadline: Instant) -> WithTimeout<Self>
fn with_deadline(self, deadline: Instant) -> WithTimeout<Self>
Add an absolute deadline to this stop. Read more