cfg-exif

Crates.iocfg-exif
lib.rscfg-exif
version0.6.0
created_at2024-08-21 10:05:05.156267+00
updated_at2025-01-22 16:26:43.840223+00
descriptionConditional compilation in expressions
homepage
repositoryhttps://github.com/raviqqe/cfg-exif
max_upload_size
id1346339
size15,735
Yota Toyama (raviqqe)

documentation

README

cfg-exif

GitHub Action Crate License

The rustfmt-friendly conditional compilation like cfg-if.

Features

  • Conditional compilation at both expression and item positions
  • rustfmt friendly

Examples

use cfg_exif::{expr, item};

item::cfg!(if (feature == "foo") {
    type Foo = usize;
} else if (target_pointer_width != "64") {
    type Foo = isize;
} else if ((target_family == "unix") && (feature == "bar")) {
    type Foo = i32;
} else if ((feature == "baz") || (target_os == "freebsd")) {
    type Foo = i64;
} else if (!(panic == "unwind")) {
    type Foo = i128;
} else {
    type Foo = f64;
});

assert_eq!(3.14 as Foo, 3.14);

assert_eq!(
    expr::cfg!(if (feature == "foo") {
        0
    } else if (target_pointer_width != "64") {
        1
    } else if ((target_family == "unix") && (feature == "bar")) {
        2
    } else if ((feature == "baz") || (target_os == "freebsd")) {
        3
    } else if (!(panic == "unwind")) {
        4
    } else {
        42
    }),
    42
);

License

The Unlicense

Commit count: 33

cargo fmt