#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

#13 in #aliasing

Download history 361/week @ 2023-12-17 354/week @ 2023-12-24 108/week @ 2023-12-31 141/week @ 2024-01-07 324/week @ 2024-01-14 136/week @ 2024-01-21 85/week @ 2024-01-28 209/week @ 2024-02-04 130/week @ 2024-02-11 178/week @ 2024-02-18 201/week @ 2024-02-25 158/week @ 2024-03-03 221/week @ 2024-03-10 201/week @ 2024-03-17 423/week @ 2024-03-24 536/week @ 2024-03-31

1,384 downloads per month
Used in 198 crates (172 directly)

MIT license

245KB
680 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

~86MB
~787K SLoC