#cfg #alias #bitcoin #projects #aliasing #gate #directive

build bitcoin-cfg

build dependency for specifying cfg aliases and cargo directives

8 releases

0.1.16-alpha.0 Mar 31, 2023
0.1.15-alpha.0 Mar 31, 2023
0.1.12-alpha.0 Jan 18, 2023

#12 in #aliasing

Download history 514/week @ 2024-03-29 176/week @ 2024-04-05 202/week @ 2024-04-12 199/week @ 2024-04-19 248/week @ 2024-04-26 197/week @ 2024-05-03 196/week @ 2024-05-10 197/week @ 2024-05-17 195/week @ 2024-05-24 153/week @ 2024-05-31 178/week @ 2024-06-07 222/week @ 2024-06-14 273/week @ 2024-06-21 97/week @ 2024-06-28 105/week @ 2024-07-05 185/week @ 2024-07-12

717 downloads per month
Used in 197 crates (171 directly)

MIT license

245KB
681 lines

bitcoin-cfg

Bitcoin-cfg is a Rust crate that provides functionality for aliasing multiple cfg gates into a single alias. This can be useful in scenarios where multiple cfg gates need to be repeated across multiple code blocks or projects.

The crate includes a cfg_alias! macro that allows developers to create a new cfg alias by combining existing cfg gates. The macro takes two arguments: the name of the new alias, and a list of cfg gates to combine.

For example, suppose a developer needs to specify that a particular code block should only be compiled on Linux x86_64 systems with the "foo" feature enabled. They could write:

#[cfg(all(target_os = "linux", target_arch = "x86_64", feature = "foo"))]
fn my_function() { /* ... */ }

However, if this cfg gate needs to be repeated across multiple code blocks or projects, it can become cumbersome to write it out each time. With bitcoin-cfg, the developer can create a new cfg alias using the cfg_alias! macro:

bitcoin_cfg::cfg_alias! {
    linux_x86_64_foo,
    all(target_os = "linux", target_arch = "x86_64", feature = "foo")
}

Then, in their code blocks, the developer can use this new alias instead of the original cfg gate:

#[cfg(linux_x86_64_foo)]
fn my_function() { /* ... */ }

This makes the code more concise and easier to read, and reduces the likelihood of errors when copying and pasting cfg gates across code blocks.

Overall, bitcoin-cfg is a useful crate for simplifying the use of cfg gates in Rust code by allowing developers to create aliases for commonly used combinations of cfg gates.

4> exactly. there are several of these which are useful in the bitcoin rust ecosystem, and they are held in this crate

bitcoin-cfg

Bitcoin-cfg is a Rust crate that provides a collection of aliases for commonly used cfg gates in the Bitcoin Rust ecosystem. It allows developers to create concise and readable cfg blocks by combining multiple cfg gates into a single alias.

The crate includes several predefined aliases for commonly used combinations of cfg gates. These aliases can be used directly in cfg blocks without having to define them manually.

For example, bitcoin_cfg::target_os_linux can be used to specify that a code block should only be compiled on Linux systems, while bitcoin_cfg::feature_serde can be used to specify that a code block requires the "serde" feature to be enabled.

In addition to the predefined aliases, bitcoin-cfg allows developers to create their own aliases using the cfg_alias! macro. This can be useful in scenarios where multiple cfg gates need to be repeated across multiple code blocks or projects.

Overall, bitcoin-cfg is a useful crate for simplifying the use of cfg gates in Rust code in the Bitcoin ecosystem by providing a collection of aliases for commonly used combinations of cfg gates.

Dependencies

~88MB
~833K SLoC