From 3ce7d1020c7f2418204a8b51ef5d6e9a9f3a17e1 Mon Sep 17 00:00:00 2001 From: Omid Rad Date: Mon, 5 Feb 2024 15:06:59 +0100 Subject: [PATCH] Compile time error, if there are zero or one features available --- CHANGELOG.md | 17 +++++++++++++++++ Cargo.toml | 2 +- examples/src/main.rs | 4 +--- src/lib.rs | 8 ++++++-- 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c748413 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 0.1.0 (2024-02-05) + +### Changed + +- Compile time error, if there are zero or one features in `exactly_one_of!` and `none_or_one_of!` macros. They were ignored before. + +## 0.0.3 (2023-11-09) + +### Added + +- It's the initial release! 🎉 diff --git a/Cargo.toml b/Cargo.toml index 773016a..29347ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mutually_exclusive_features" -version = "0.0.3" +version = "0.1.0" description = "Macros to check that only none or one of a set of features is enabled at a time, as known as mutually exclusive features" license = "MIT OR Apache-2.0" authors = ["Omid Rad "] diff --git a/examples/src/main.rs b/examples/src/main.rs index 8182bdf..a40c1b1 100644 --- a/examples/src/main.rs +++ b/examples/src/main.rs @@ -3,8 +3,6 @@ use mutually_exclusive_features::{exactly_one_of, none_or_one_of}; fn main() { none_or_one_of!("a", "b", "c"); none_or_one_of!("a", "b",); - none_or_one_of!("a"); - none_or_one_of!(); exactly_one_of!("a", "b", "c"); -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index 2ce4f8f..17bc91d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,8 +51,12 @@ macro_rules! none_or_one_of { }; // ignore cases - () => {}; - (@recurs: [params: $F1:literal,]) => {}; + () => { + compile_error!("It doesn't make sense to call it with no feature! Probably you can safely remove it.") + }; + (@recurs: [params: $F1:literal,]) => { + compile_error!("It doesn't make sense to call it with only one feature! Probably you can safely remove it.") + }; } /**