about summary refs log tree commit diff
path: root/src/libstd/num
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-06-14 18:27:52 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-06-14 19:12:37 -0700
commit893c70d7bc670054ef646b71d4d503298cc50d76 (patch)
tree2903a8e7a012b17c6f8ad9efff4f18e76d12051d /src/libstd/num
parent07f5ab10096718a296825b3b628081559d738810 (diff)
downloadrust-893c70d7bc670054ef646b71d4d503298cc50d76.tar.gz
rust-893c70d7bc670054ef646b71d4d503298cc50d76.zip
Add Zero impls for lots of common types
Diffstat (limited to 'src/libstd/num')
-rw-r--r--src/libstd/num/num.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs
index a9893579721..4681e4f4f53 100644
--- a/src/libstd/num/num.rs
+++ b/src/libstd/num/num.rs
@@ -418,6 +418,21 @@ pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(radix: uint, pow
     total
 }
 
+impl<T: Zero> Zero for @mut T {
+    fn zero() -> @mut T { @mut Zero::zero() }
+    fn is_zero(&self) -> bool { (**self).is_zero() }
+}
+
+impl<T: Zero> Zero for @T {
+    fn zero() -> @T { @Zero::zero() }
+    fn is_zero(&self) -> bool { (**self).is_zero() }
+}
+
+impl<T: Zero> Zero for ~T {
+    fn zero() -> ~T { ~Zero::zero() }
+    fn is_zero(&self) -> bool { (**self).is_zero() }
+}
+
 /// Helper function for testing numeric operations
 #[cfg(test)]
 pub fn test_num<T:Num + NumCast>(ten: T, two: T) {