Struct mimicry::AnswersGuard
source · pub struct AnswersGuard<'a, V> { /* private fields */ }
Expand description
Guard ensuring that answers sent from an AnswersSender
are timely consumed.
The consumption check is performed on guard drop: either implicit, or explicit
via Self::scope()
.
Implementations
sourceimpl<V> AnswersGuard<'_, V>
impl<V> AnswersGuard<'_, V>
sourcepub fn scope<R>(self, action: impl FnOnce() -> R) -> R
pub fn scope<R>(self, action: impl FnOnce() -> R) -> R
Executes the provided closure and checks that all the answers were consumed by it.
sourcepub async fn async_scope<Fut: Future>(self, action: Fut) -> Fut::Output
pub async fn async_scope<Fut: Future>(self, action: Fut) -> Fut::Output
Executes the provided future and checks that all the answers were consumed by it.
While Self::scope()
.await
with a closure that returns a future technically works,
it will probably result in a failed consumption check. Indeed, the scope
will be exited and the guard dropped before the future is polled.
Trait Implementations
sourceimpl<'a, V: Debug> Debug for AnswersGuard<'a, V>
impl<'a, V: Debug> Debug for AnswersGuard<'a, V>
Auto Trait Implementations
impl<'a, V> !RefUnwindSafe for AnswersGuard<'a, V>
impl<'a, V> Send for AnswersGuard<'a, V>where
V: Send,
impl<'a, V> Sync for AnswersGuard<'a, V>where
V: Send,
impl<'a, V> Unpin for AnswersGuard<'a, V>
impl<'a, V> !UnwindSafe for AnswersGuard<'a, V>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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