Module consumer

Module consumer 

Source
Expand description

§Consumer Types

Provides implementations of readonly consumer interfaces for executing operations that neither modify their own state nor modify input values.

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

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

  • BoxConsumer<T>: Box-based single ownership implementation
  • ArcConsumer<T>: Arc-based thread-safe shared ownership implementation
  • RcConsumer<T>: Rc-based single-threaded shared ownership implementation

§Design Philosophy

Consumer uses Fn(&T) semantics, neither modifying its own state nor modifying input values.

Suitable for pure observation, logging, notification and other scenarios. Compared to Consumer, Consumer does not require interior mutability (Mutex/RefCell), making it more efficient and easier to share.

§Author

Haixing Hu

Structs§

ArcConditionalConsumer
ArcConditionalConsumer struct
ArcConsumer
ArcConsumer struct
BoxConditionalConsumer
BoxConditionalConsumer struct
BoxConsumer
BoxConsumer struct
RcConditionalConsumer
RcConditionalConsumer struct
RcConsumer
RcConsumer struct

Traits§

Consumer
Consumer trait - Unified readonly consumer interface
FnConsumerOps
Extension trait providing readonly consumer composition methods for closures