iff 0.1.0

A macro for if / if let chains until [RFC 2497] is implemented.
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 0 items with examples
  • Size
  • Source code size: 3.13 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.09 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • utkarshkukreti/iff.rs
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • utkarshkukreti

iff.rs

A macro for if / if let chains until RFC 2497 is implemented.

Usage

use iff::iff;

fn go(var: Option<Vec<i32>>) {
    print!("{:?}", var);
    iff! {
        let Some(x) = var,
        let [y, _] = &*x,
        *y == 0 => {
            print!(" => ok")
        }
    }
    println!("");
}

fn main() {
    go(None);
    go(Some(vec![]));
    go(Some(vec![0]));
    go(Some(vec![0, 1]));
    go(Some(vec![0, 1, 2]));
}

Output:

None
Some([])
Some([0])
Some([0, 1]) => ok
Some([0, 1, 2])