diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2012-12-20 07:14:38 -0800 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2012-12-20 07:15:04 -0800 |
| commit | e8102e73a91de261556cddd0d055e69234a37a82 (patch) | |
| tree | bc02ee400393f97966917048649397d20b73f8b3 /src/libcore/uint-template.rs | |
| parent | 8554d5e7104be30d20ce8e8dc08239ce20b171c2 (diff) | |
core: Add a Zero and One trait to num
I believe these are the last traits we need in order to start grouping our numerical types into mathematical groups and rings.
Diffstat (limited to 'src/libcore/uint-template.rs')
| -rw-r--r-- | src/libcore/uint-template.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 1a9bca92d1f..80b393a813c 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -85,6 +85,14 @@ impl T: num::Num { static pure fn from_int(n: int) -> T { return n as T; } } +impl T: num::Zero { + static pure fn zero() -> T { 0 } +} + +impl T: num::One { + static pure fn one() -> T { 1 } +} + impl T: iter::Times { #[inline(always)] #[doc = "A convenience form for basic iteration. Given a variable `x` \ |
