Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

operator_identity

crates.io ci codecov license

The identity operator is a no-op operator.

In layman’s terms: speedy thing goes in, speedy thing comes out.

It is used to conveniently define the input types of a composite operator. This is why only this operator has a standalone compose_operator function and has no Observable extension methods.

See Also

Example

cargo run -p rx_core --example operator_identity_example
// If it would exist, this would be the same as: `just(1).identity().subscribe(...)`
let _s = IdentityOperator::default()
    .operate(just(1))
    .subscribe(PrintObserver::new("identity_operator"));
identity_operator - next: 1
identity_operator - completed
identity_operator - unsubscribed

Example (Composite)

cargo run -p rx_core --example operator_identity_composite_example
let composite_operator = compose_operator::<i32, Never>()
    .map(|i| i + 1)
    .filter(|i, _| i < &4);

let _s = (1..=5)
    .into_observable()
    .pipe(composite_operator)
    .subscribe(PrintObserver::new("identity_operator (composite)"));
identity_operator (composite) - next: 2
identity_operator (composite) - next: 3
identity_operator (composite) - completed
identity_operator (composite) - unsubscribed