Crates.io | feature_utils |
lib.rs | feature_utils |
version | 0.0.0 |
source | src |
created_at | 2022-11-22 06:23:16.362897 |
updated_at | 2022-11-22 06:23:16.362897 |
description | Macros for good compiler errors when dealing with feature flags |
homepage | |
repository | https://github.com/TheButlah/feature_utils |
max_upload_size | |
id | 720634 |
size | 16,375 |
This crate implements a collection of helpful feature-related macros. These macros serve to make it easy to have helpful compiler messages when dealing with sets of related, sometimes mutually exclusive features.
We are pre-0.1, so we make no stability guarantees currently. Cargo consideres 0.0.* to mean that all new versions are possibly breaking changes.
Inside build.rs
:
// Each of these embedded microcontrollers are mutually exclusive and at least one
// must be provided.
feature_utils::mandatory_and_unique!("esp32c3", "esp8266", "nrf52840");
fn main() {}
This results in one message if you don't pass any features:
error: You must provide one of the mandatory features!
--> src/lib.rs:18:1
|
5 | feature_utils::mandatory_and_unique!("esp32c3", "esp8266", "nrf52840");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `$crate::at_least_one_provided` which comes
from the expansion of the macro `feature_utils::mandatory_and_unique` (in Nightly
builds, run with -Z macro-backtrace for more info)
And another message if you pass multiple mutually exclusive features:
error: features "esp32c3" and "nrf52840" cannot be used together!
--> src/lib.rs:18:1
|
5 | feature_utils::mandatory_and_unique!("esp32c3", "esp8266", "nrf52840");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `$crate::unique` which comes from the
expansion of the macro `feature_utils::mandatory_and_unique` (in Nightly builds, run
with -Z macro-backtrace for more info)
All code in this repository is dual-licensed under either:
at your option. This means you can select the license you prefer!
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.