about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>2013-07-07 22:32:02 +1000
committerDaniel Micay <danielmicay@gmail.com>2013-07-09 16:35:56 -0400
commit763d846dd3db43751eba5b53b6923b8355581063 (patch)
tree02395dace9664a4848cf29274d99788c34e76265
parentf2bd4416fa3549f962c8ffdd6474cf4bf0d21eca (diff)
downloadrust-763d846dd3db43751eba5b53b6923b8355581063.tar.gz
rust-763d846dd3db43751eba5b53b6923b8355581063.zip
Impl Not for bool
-rw-r--r--src/libstd/bool.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs
index b0b586df4b5..126650981cd 100644
--- a/src/libstd/bool.rs
+++ b/src/libstd/bool.rs
@@ -19,6 +19,8 @@ A quick summary:
 Implementations of the following traits:
 
 * `FromStr`
+* `ToStr`
+* `Not`
 * `Ord`
 * `TotalOrd`
 * `Eq`
@@ -36,6 +38,8 @@ Finally, some inquries into the nature of truth: `is_true` and `is_false`.
 
 #[cfg(not(test))]
 use cmp::{Eq, Ord, TotalOrd, Ordering};
+#[cfg(not(test))]
+use ops::Not;
 use option::{None, Option, Some};
 use from_str::FromStr;
 use to_str::ToStr;
@@ -254,6 +258,27 @@ pub fn all_values(blk: &fn(v: bool)) {
 #[inline]
 pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
 
+/**
+* The logical complement of a boolean value.
+*
+* # Examples
+*
+* ~~~rust
+* rusti> !true
+* false
+* ~~~
+*
+* ~~~rust
+* rusti> !false
+* true
+* ~~~
+*/
+#[cfg(not(test))]
+impl Not<bool> for bool {
+    #[inline]
+    fn not(&self) -> bool { !*self }
+}
+
 #[cfg(not(test))]
 impl Ord for bool {
     #[inline]