about summary refs log tree commit diff
path: root/src/libstd/iter.rs
diff options
context:
space:
mode:
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-01-18 17:08:23 +1100
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-01-20 18:09:46 +1100
commitcf56624a4ad7703c8f3fc327b8c385da0a803ea5 (patch)
tree0a46f95db2c26f4beb50f7785a82f46348ff9083 /src/libstd/iter.rs
parent764f2cb6f3517869e31fc7b93ff11dd840db8d30 (diff)
downloadrust-cf56624a4ad7703c8f3fc327b8c385da0a803ea5.tar.gz
rust-cf56624a4ad7703c8f3fc327b8c385da0a803ea5.zip
Add operator trait constraints to std::num::{Zero, One} and document their appropriate use
Zero and One have precise definitions in mathematics. Documentation has been added to describe the appropriate uses for these traits and the laws that they should satisfy.

For more information regarding these identities, see the following wikipedia pages:

- http://wikipedia.org/wiki/Additive_identity
- http://wikipedia.org/wiki/Multiplicative_identity
Diffstat (limited to 'src/libstd/iter.rs')
-rw-r--r--src/libstd/iter.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs
index fcf0f4f2444..8081c6ed8db 100644
--- a/src/libstd/iter.rs
+++ b/src/libstd/iter.rs
@@ -2872,6 +2872,12 @@ mod tests {
             }
         }
 
+        impl Mul<Foo, Foo> for Foo {
+            fn mul(&self, _: &Foo) -> Foo {
+                Foo
+            }
+        }
+
         impl num::One for Foo {
             fn one() -> Foo {
                 Foo