From a138a003bb31cefbdb4ac8508efe6de64aa9da3f Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Fri, 26 Nov 2021 22:32:53 +0100 Subject: First version Already quite stable --- src/lib.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/lib.rs (limited to 'src') 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(x: T) -> ::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); + } +} -- cgit v1.2.3