diff options
Diffstat (limited to 'src/libcore/uint-template.rs')
| -rw-r--r-- | src/libcore/uint-template.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index d5f0cc465c7..5d8c9415a77 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -12,7 +12,7 @@ export range; export compl; export to_str, to_str_bytes; export from_str, from_str_radix, str, parse_buf; -export ord, eq, num; +export ord, eq, extensions; const min_value: T = 0 as T; const max_value: T = 0 as T - 1 as T; @@ -65,16 +65,18 @@ impl eq of eq for T { } } -impl num of num::num for T { - fn add(&&other: T) -> T { ret self + other; } - fn sub(&&other: T) -> T { ret self - other; } - fn mul(&&other: T) -> T { ret self * other; } - fn div(&&other: T) -> T { ret self / other; } - fn modulo(&&other: T) -> T { ret self % other; } - fn neg() -> T { ret -self; } - - fn to_int() -> int { ret self as int; } - fn from_int(n: int) -> T { ret n as T; } +mod extensions { + impl num of num::num for T { + fn add(&&other: T) -> T { ret self + other; } + fn sub(&&other: T) -> T { ret self - other; } + fn mul(&&other: T) -> T { ret self * other; } + fn div(&&other: T) -> T { ret self / other; } + fn modulo(&&other: T) -> T { ret self % other; } + fn neg() -> T { ret -self; } + + fn to_int() -> int { ret self as int; } + fn from_int(n: int) -> T { ret n as T; } + } } #[doc = " |
