pub trait ValidMutBorrowCommutativityFor<F: FnMut(&In) -> Out, In: ?Sized, Out, O: Ordering, const WAS_MUT: bool>: Sealed<F, In, Out, O, WAS_MUT> { }Expand description
Marker trait for commutativity of closures that borrow their input (FnMut(&In) -> Out).
A proof is required when the stream is unordered and the closure mutably captures
state (WAS_MUT). Definition (borrowing closures, |item: &T| -> Out, e.g.
filter / inspect): processing any two items in either order must (1) leave the
mutably-captured state (e.g. Singleton::by_mut references) in the same final
value, and (2) keep the operator’s observable output identical as a multiset. For
filter, the outputs are the retained elements, so the predicate’s decisions
must not depend on the processing order: a stateful predicate like a rate limiter is
not commutative — its budget converges either way, but which element passes
depends on the order. For inspect, the elements pass through unchanged, so only
condition (1) applies.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".