pub struct BoxedStop(/* private fields */);Expand description
A heap-allocated Stop implementation.
This type provides dynamic dispatch for Stop, avoiding monomorphization
bloat when you don’t need the performance of generics.
§Example
use almost_enough::{BoxedStop, StopSource, Stopper, Never, Stop};
fn process(stop: BoxedStop) {
for i in 0..1000 {
if i % 100 == 0 && stop.should_stop() {
return;
}
// process...
}
}
// Works with any Stop implementation
process(BoxedStop::new(Never));
process(BoxedStop::new(StopSource::new()));
process(BoxedStop::new(Stopper::new()));Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BoxedStop
impl !RefUnwindSafe for BoxedStop
impl Send for BoxedStop
impl Sync for BoxedStop
impl Unpin for BoxedStop
impl !UnwindSafe for BoxedStop
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> 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