apply_conditionally 2.0.0

Chain and apply methods on objects conditionally.
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented3 out of 4 items with examples
  • Size
  • Source code size: 11.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 687.05 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • SFM61319/apply_conditionally
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • SFM61319

Apply Conditionally

Chain and apply methods on objects conditionally.

Installation

  1. Using cargo:
cargo add apply_conditionally
  1. By updating Cargo.toml:
[dependencies]
apply_conditionally = "1.0.0"

Usage

// 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();
}

License

Licensed under the MIT License.