pub trait ConsumedEvent {
// Required method
fn is_consumed(&self) -> bool;
// Provided methods
fn or_else<F>(self, f: F) -> Self
where F: FnOnce() -> Self,
Self: Sized { ... }
fn or_else_try<F, E>(self, f: F) -> Result<Self, E>
where Self: Sized,
F: FnOnce() -> Result<Self, E> { ... }
fn and_then<F>(self, f: F) -> Self
where Self: Sized + Ord,
F: FnOnce() -> Self { ... }
fn and_then_try<F, E>(self, f: F) -> Result<Self, E>
where Self: Sized + Ord,
F: FnOnce() -> Result<Self, E> { ... }
fn and<F>(self, f: F) -> Self
where Self: Sized + Ord,
F: FnOnce() -> Self { ... }
fn and_try<F, E>(self, f: F) -> Result<Self, E>
where Self: Sized + Ord,
F: FnOnce() -> Result<Self, E> { ... }
}Expand description
When calling multiple event-handlers, the minimum information required from the result is ‘has consumed/didn’t consume’ the event.
The event-handler may also react to the event and not call it ‘consuming the event’. But this is tricky, non-obvious and frowned upon. The caller may also just ignore the fact.
See also flow and try_flow and the extra break_flow.
Required Methods§
Sourcefn is_consumed(&self) -> bool
fn is_consumed(&self) -> bool
Is this the ‘consumed’ result.
Provided Methods§
Sourcefn or_else_try<F, E>(self, f: F) -> Result<Self, E>
fn or_else_try<F, E>(self, f: F) -> Result<Self, E>
Or-Else chaining with is_consumed() as the split.
Sourcefn and_then<F>(self, f: F) -> Self
fn and_then<F>(self, f: F) -> Self
And_then-chaining based on is_consumed(). Returns max(self, f()).
Sourcefn and_then_try<F, E>(self, f: F) -> Result<Self, E>
fn and_then_try<F, E>(self, f: F) -> Result<Self, E>
And_then-chaining based on is_consumed(). Returns max(self, f()).