diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-08-14 20:03:31 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-08-14 20:03:31 -0700 |
| commit | ccd36439f70814073c567bb22fdbcaafcf970b16 (patch) | |
| tree | 6fb5ae755f4dafa8b9c7ee256d15008d376baf69 /src/libcore/float.rs | |
| parent | f78c90653535128b5a7c08d4850d6ef202beba40 (diff) | |
| download | rust-ccd36439f70814073c567bb22fdbcaafcf970b16.tar.gz rust-ccd36439f70814073c567bb22fdbcaafcf970b16.zip | |
Make Num::from_int a static method
Diffstat (limited to 'src/libcore/float.rs')
| -rw-r--r-- | src/libcore/float.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libcore/float.rs b/src/libcore/float.rs index 79e89714728..943f075b319 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -422,7 +422,7 @@ impl float: num::Num { pure fn neg() -> float { return -self; } pure fn to_int() -> int { return self as int; } - pure fn from_int(n: int) -> float { return n as float; } + static pure fn from_int(n: int) -> float { return n as float; } } #[test] @@ -523,14 +523,14 @@ fn test_traits() { fn test<U:num::Num>(ten: &U) { assert (ten.to_int() == 10); - let two = ten.from_int(2); + let two = from_int(2); assert (two.to_int() == 2); - assert (ten.add(two) == ten.from_int(12)); - assert (ten.sub(two) == ten.from_int(8)); - assert (ten.mul(two) == ten.from_int(20)); - assert (ten.div(two) == ten.from_int(5)); - assert (ten.modulo(two) == ten.from_int(0)); + assert (ten.add(two) == from_int(12)); + assert (ten.sub(two) == from_int(8)); + assert (ten.mul(two) == from_int(20)); + assert (ten.div(two) == from_int(5)); + assert (ten.modulo(two) == from_int(0)); } test(&10.0); |
