summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2021-11-26 22:32:53 +0100
committerChristoph Schlosser <christoph@linux.com>2021-11-26 22:35:28 +0100
commita138a003bb31cefbdb4ac8508efe6de64aa9da3f (patch)
treefec1274a638721609ffca3ea6a8104eeb2c8212f /src
downloadnicht-a138a003bb31cefbdb4ac8508efe6de64aa9da3f.tar.gz
First versionHEADmaster
Already quite stable
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs32
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);
+ }
+}