Skip to main content

Module bi_consumer

Module bi_consumer 

Source
Expand description

§BiConsumer Types

Provides non-mutating bi-consumer interface implementations for operations that accept two input parameters without modifying their own state or the input values.

It is similar to the Fn(&T, &U) trait in the standard library.

This module provides a unified BiConsumer trait and three concrete implementations based on different ownership models:

  • BoxBiConsumer<T, U>: Box-based single ownership
  • ArcBiConsumer<T, U>: Arc-based thread-safe shared ownership
  • RcBiConsumer<T, U>: Rc-based single-threaded shared ownership

§Design Philosophy

BiConsumer uses Fn(&T, &U) semantics: it is invoked through &self and receives shared references to both input values.

Suitable for pure observation, logging, and notification scenarios with two parameters. Compared to StatefulBiConsumer, BiConsumer does not require wrapper-level interior mutability (Mutex/RefCell), making it more efficient and easier to share.

§Author

Haixing Hu

Structs§

ArcBiConsumer
ArcBiConsumer struct
ArcConditionalBiConsumer
ArcConditionalBiConsumer struct
BoxBiConsumer
BoxBiConsumer struct
BoxConditionalBiConsumer
BoxConditionalBiConsumer struct
RcBiConsumer
RcBiConsumer struct
RcConditionalBiConsumer
RcConditionalBiConsumer struct

Traits§

BiConsumer
BiConsumer trait - Unified non-mutating bi-consumer interface
FnBiConsumerOps
Extension trait providing non-mutating bi-consumer composition methods for closures