1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//! # assert_not - Inverse Assertion Macros for Rust
//!
//! This crate provides macros for asserting that conditions are **NOT** true,
//! which is the inverse behavior of Rust's standard `assert!` macro.
//!
//! ## Why use assert_not?
//!
//! While `assert!` verifies that a condition is true, sometimes you need to ensure
//! that a condition is explicitly false. Instead of writing `assert!(!condition)`,
//! `assert_not!(condition)` provides clearer intent and better readability.
//!
//! ## Features
//!
//! - **`assert_not!`** - Runtime assertion that panics if condition is true
//! - **`debug_assert_not!`** - Debug-only assertion (removed in release builds)
//! - **`no_std` compatible** - Works in embedded and bare-metal environments
//! - **Zero runtime overhead** in release builds (for debug variants)
//! - **Custom error messages** with format string support
//!
//! ## Quick Start
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! # For tests (most common)
//! [dev-dependencies]
//! assert-not = "0.1.0"
//!
//! # For runtime use
//! [dependencies]
//! assert-not = "0.1.0"
//! ```
//!
//! Basic usage:
//!
//! ```rust
//! use assert_not::assert_not;
//!
//! assert_not!(false); // ✓ Passes
//! let x = 5;
//! assert_not!(x == 0, "x should not be zero"); // ✓ With message
//! ```
//!
//! ## Common Use Cases
//!
//! ```rust
//! use assert_not::assert_not;
//!
//! #[derive(PartialEq)]
//! enum Status { Error, Ok }
//!
//! let value = 10;
//! let state = Status::Ok;
//! let config = Some("config");
//!
//! // Input validation
//! assert_not!(value < 0, "Value must be positive");
//!
//! // State validation
//! assert_not!(state == Status::Error, "Cannot proceed in error state");
//!
//! // Optional values
//! assert_not!(config.is_none(), "Configuration required");
//! ```
//!
//! ## Comparison with Standard Assertions
//!
//! ```rust
//! use assert_not::assert_not;
//!
//! let x = 5;
//! let list = vec![1, 2, 3];
//!
//! // Instead of:
//! assert!(x != 0);
//! assert!(!list.is_empty());
//!
//! // You can write:
//! assert_not!(x == 0);
//! assert_not!(list.is_empty());
//! ```
/// Asserts that a condition is **NOT** true.
///
/// Panics if the condition is `true`, does nothing if `false`.
///
/// # Examples
///
/// ```
/// use assert_not::assert_not;
///
/// assert_not!(false); // ✓ Passes
/// assert_not!(2 + 2 == 5); // ✓ Passes
/// assert_not!(false, "Custom message"); // ✓ With message
///
/// // These would panic:
/// // assert_not!(true);
/// // assert_not!(2 + 2 == 4);
/// ```
/// Debug-only version of `assert_not!`.
///
/// Only active in debug builds - completely removed in release builds.
///
/// # Examples
///
/// ```
/// use assert_not::debug_assert_not;
///
/// fn expensive_check() -> bool { false }
///
/// debug_assert_not!(false); // ✓ Checked in debug, ignored in release
/// debug_assert_not!(expensive_check(), "Debug validation failed");
/// ```
/// # More Examples
///
/// ```rust
/// use assert_not::{assert_not, debug_assert_not};
///
/// // Function validation
/// fn divide(a: f64, b: f64) -> f64 {
/// assert_not!(b == 0.0, "Division by zero");
/// a / b
/// }
///
/// // Debug-only checks (removed in release builds)
/// fn process(data: &[i32]) {
/// debug_assert_not!(data.is_empty(), "Empty data in debug");
/// // ... processing
/// }
///
/// // Example usage
/// let result = divide(10.0, 2.0);
/// process(&[1, 2, 3]);
/// ```