diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..8823931 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,32 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +//! A more natural way to use `not` +//! +//! # Examples +//! +//! ``` +//! use nicht::not; +//! +//! assert_eq!(not(true), false); +//! ``` + +use std::ops::Not; + +pub fn not<T: Not>(x: T) -> <T as Not>::Output { + Not::not(x) +} + +#[cfg(test)] +mod tests { + use crate::not; + + #[test] + fn primitive_data_type() { + assert_eq!(not(true), false); + assert_eq!(not(false), true); + assert_ne!(not(true), true); + assert_ne!(not(false), false); + } +} |