#table #cfg #macro #utility

build cfg_table

A simple macro that expands to different values across compilation targets

2 releases (1 stable)

1.0.0 Nov 26, 2021
0.1.1 Sep 23, 2021
0.1.0 Sep 23, 2021

#189 in FFI

Download history 54/week @ 2024-07-22 20/week @ 2024-07-29 19/week @ 2024-08-05 22/week @ 2024-08-12 8/week @ 2024-08-19 15/week @ 2024-08-26 24/week @ 2024-09-02 25/week @ 2024-09-09 21/week @ 2024-09-16 40/week @ 2024-09-23 26/week @ 2024-09-30 28/week @ 2024-10-14 13/week @ 2024-10-21 39/week @ 2024-10-28 31/week @ 2024-11-04

111 downloads per month
Used in 2 crates (via gmod)

MIT license

9KB
121 lines

crates.io

cfg_table

A simple macro that expands to different values across compilation targets.

Panics

This macro will panic at runtime if no matching value is found.

Example

#[macro_use] extern crate cfg_table;

let var = cfg_table! {
    [all(target_os = "freebsd", target_pointer_width = "64", feature = "my-feature")] => 1337, // custom

    // common platforms
    win32 => 32,
    win64 => 64,
    linux32 => 32,
    linux64 => 64,
    macos32 => 32,
    macos64 => 64,

    // pointer widths
    32 => 1985,
    "32" => 1985,
    64 => 2003,
    "64" => 2003,

    _ => 123, // default value if nothing matches, this must be at the bottom
};

cfg_table! {
    win32 => {
        println!("You're on Windows 32-bit!");
    },

    win64 => {
        println!("You're on Windows 64-bit!");
    },

    _ => {
        panic!("What the heck is a \"Linux\"?");
    },
};

No runtime deps

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy