Chain and apply methods on objects conditionally.
- Using
cargo
:
cargo add apply_conditionally
- By updating
Cargo.toml
:
[dependencies]
apply_conditionally = "1.0.0"
// Bring the trait into scope to access the trait methods on objects
use apply_conditionally::ApplyConditionally;
fn foo<T>(value: T, condition: bool) {
value
.apply(bar)
.apply_if(condition, baz)
.some_other_method();
}
Licensed under the MIT License.