about summary refs log tree commit diff
path: root/src/libstd/bool.rs
diff options
context:
space:
mode:
authorBirunthan Mohanathas <birunthan@mohanathas.com>2013-07-24 22:37:48 +0300
committerBirunthan Mohanathas <birunthan@mohanathas.com>2013-07-24 22:54:32 +0300
commitf73bb2bfe637b7e0edd8086fe8ba45032d8e3320 (patch)
tree859eaa7c5f88589864c1895afb558654d8c28e46 /src/libstd/bool.rs
parentf132401a0b4f7fe19f9de50ab5a5a6a0d1d68607 (diff)
downloadrust-f73bb2bfe637b7e0edd8086fe8ba45032d8e3320.tar.gz
rust-f73bb2bfe637b7e0edd8086fe8ba45032d8e3320.zip
Implement std::num::Zero for bool
Closes #8024.
Diffstat (limited to 'src/libstd/bool.rs')
-rw-r--r--src/libstd/bool.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs
index 126650981cd..eeaea6a2cff 100644
--- a/src/libstd/bool.rs
+++ b/src/libstd/bool.rs
@@ -24,6 +24,7 @@ Implementations of the following traits:
 * `Ord`
 * `TotalOrd`
 * `Eq`
+* `Zero`
 
 ## Various functions to compare `bool`s
 
@@ -36,14 +37,14 @@ 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;
 
+#[cfg(not(test))] use cmp::{Eq, Ord, TotalOrd, Ordering};
+#[cfg(not(test))] use ops::Not;
+#[cfg(not(test))] use num::Zero;
+
 /**
 * Negation of a boolean value.
 *
@@ -330,6 +331,12 @@ impl Eq for bool {
     fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
 }
 
+#[cfg(not(test))]
+impl Zero for bool {
+    fn zero() -> bool { false }
+    fn is_zero(&self) -> bool { *self == false }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;