diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-08-30 12:54:50 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-08-31 16:21:47 -0700 |
| commit | 4128cc4cb44acb415be3cfdfa008fd6c95ceee74 (patch) | |
| tree | 321c8c7ed1c28247377bf4122365c047d69f891f /src/libcore | |
| parent | 638db28c472c1edadc3c37f900df28f14cca7665 (diff) | |
| download | rust-4128cc4cb44acb415be3cfdfa008fd6c95ceee74.tar.gz rust-4128cc4cb44acb415be3cfdfa008fd6c95ceee74.zip | |
Make utility funs in core::int, core::uint, etc. not by-reference
Closes #3302
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/int-template.rs | 30 | ||||
| -rw-r--r-- | src/libcore/int-template/int.rs | 6 | ||||
| -rw-r--r-- | src/libcore/io.rs | 4 | ||||
| -rw-r--r-- | src/libcore/str.rs | 4 | ||||
| -rw-r--r-- | src/libcore/uint-template.rs | 30 | ||||
| -rw-r--r-- | src/libcore/uint-template/uint.rs | 4 | ||||
| -rw-r--r-- | src/libcore/vec.rs | 4 |
7 files changed, 41 insertions, 41 deletions
diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index 6b572d12626..bc080ac0d63 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -25,21 +25,21 @@ const bytes : uint = (inst::bits / 8); const min_value: T = (-1 as T) << (bits - 1); const max_value: T = min_value - 1 as T; -pure fn min(x: &T, y: &T) -> T { if *x < *y { *x } else { *y } } -pure fn max(x: &T, y: &T) -> T { if *x > *y { *x } else { *y } } - -pure fn add(x: &T, y: &T) -> T { *x + *y } -pure fn sub(x: &T, y: &T) -> T { *x - *y } -pure fn mul(x: &T, y: &T) -> T { *x * *y } -pure fn div(x: &T, y: &T) -> T { *x / *y } -pure fn rem(x: &T, y: &T) -> T { *x % *y } - -pure fn lt(x: &T, y: &T) -> bool { *x < *y } -pure fn le(x: &T, y: &T) -> bool { *x <= *y } -pure fn eq(x: &T, y: &T) -> bool { *x == *y } -pure fn ne(x: &T, y: &T) -> bool { *x != *y } -pure fn ge(x: &T, y: &T) -> bool { *x >= *y } -pure fn gt(x: &T, y: &T) -> bool { *x > *y } +pure fn min(x: T, y: T) -> T { if x < y { x } else { y } } +pure fn max(x: T, y: T) -> T { if x > y { x } else { y } } + +pure fn add(x: T, y: T) -> T { x + y } +pure fn sub(x: T, y: T) -> T { x - y } +pure fn mul(x: T, y: T) -> T { x * y } +pure fn div(x: T, y: T) -> T { x / y } +pure fn rem(x: T, y: T) -> T { x % y } + +pure fn lt(x: T, y: T) -> bool { x < y } +pure fn le(x: T, y: T) -> bool { x <= y } +pure fn eq(x: T, y: T) -> bool { x == y } +pure fn ne(x: T, y: T) -> bool { x != y } +pure fn ge(x: T, y: T) -> bool { x >= y } +pure fn gt(x: T, y: T) -> bool { x > y } pure fn is_positive(x: T) -> bool { x > 0 as T } pure fn is_negative(x: T) -> bool { x < 0 as T } diff --git a/src/libcore/int-template/int.rs b/src/libcore/int-template/int.rs index 96ca59335a5..d990ba97afa 100644 --- a/src/libcore/int-template/int.rs +++ b/src/libcore/int-template/int.rs @@ -2,9 +2,9 @@ type T = int; const bits: uint = uint::bits; /// Produce a uint suitable for use in a hash table -pure fn hash(x: &int) -> uint { - let u : uint = *x as uint; - uint::hash(&u) +pure fn hash(x: int) -> uint { + let u : uint = x as uint; + uint::hash(u) } /// Returns `base` raised to the power of `exponent` diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 9ba942cb0b7..f351ee77caa 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -285,7 +285,7 @@ type ByteBuf = {buf: &[const u8], mut pos: uint}; impl ByteBuf: Reader { fn read(buf: &[mut u8], len: uint) -> uint { - let count = uint::min(&len, &(self.buf.len() - self.pos)); + let count = uint::min(len, self.buf.len() - self.pos); vec::u8::memcpy(buf, vec::const_view(self.buf, self.pos, self.buf.len()), @@ -668,7 +668,7 @@ impl MemBuffer: Writer { let v_len = v.len(); let buf_len = buf.len(); - let count = uint::max(&buf_len, &(self.pos + v_len)); + let count = uint::max(buf_len, self.pos + v_len); vec::reserve(buf, count); unsafe { vec::unsafe::set_len(buf, count); } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 888d992321c..d2c9a07319a 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -682,7 +682,7 @@ pure fn eq(a: &~str, b: &~str) -> bool { /// Bytewise slice less than pure fn lt(a: &str, b: &str) -> bool { let (a_len, b_len) = (a.len(), b.len()); - let mut end = uint::min(&a_len, &b_len); + let mut end = uint::min(a_len, b_len); let mut i = 0; while i < end { @@ -698,7 +698,7 @@ pure fn lt(a: &str, b: &str) -> bool { /// Bytewise less than or equal pure fn le(a: &str, b: &str) -> bool { let (a_len, b_len) = (a.len(), b.len()); - let mut end = uint::min(&a_len, &b_len); + let mut end = uint::min(a_len, b_len); let mut i = 0; while i < end { diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 5119a5dd562..dfab2e36096 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -24,21 +24,21 @@ const bytes : uint = (inst::bits / 8); const min_value: T = 0 as T; const max_value: T = 0 as T - 1 as T; -pure fn min(x: &T, y: &T) -> T { if *x < *y { *x } else { *y } } -pure fn max(x: &T, y: &T) -> T { if *x > *y { *x } else { *y } } - -pure fn add(x: &T, y: &T) -> T { *x + *y } -pure fn sub(x: &T, y: &T) -> T { *x - *y } -pure fn mul(x: &T, y: &T) -> T { *x * *y } -pure fn div(x: &T, y: &T) -> T { *x / *y } -pure fn rem(x: &T, y: &T) -> T { *x % *y } - -pure fn lt(x: &T, y: &T) -> bool { *x < *y } -pure fn le(x: &T, y: &T) -> bool { *x <= *y } -pure fn eq(x: &T, y: &T) -> bool { *x == *y } -pure fn ne(x: &T, y: &T) -> bool { *x != *y } -pure fn ge(x: &T, y: &T) -> bool { *x >= *y } -pure fn gt(x: &T, y: &T) -> bool { *x > *y } +pure fn min(x: T, y: T) -> T { if x < y { x } else { y } } +pure fn max(x: T, y: T) -> T { if x > y { x } else { y } } + +pure fn add(x: T, y: T) -> T { x + y } +pure fn sub(x: T, y: T) -> T { x - y } +pure fn mul(x: T, y: T) -> T { x * y } +pure fn div(x: T, y: T) -> T { x / y } +pure fn rem(x: T, y: T) -> T { x % y } + +pure fn lt(x: T, y: T) -> bool { x < y } +pure fn le(x: T, y: T) -> bool { x <= y } +pure fn eq(x: T, y: T) -> bool { x == y } +pure fn ne(x: T, y: T) -> bool { x != y } +pure fn ge(x: T, y: T) -> bool { x >= y } +pure fn gt(x: T, y: T) -> bool { x > y } pure fn is_positive(x: T) -> bool { x > 0 as T } pure fn is_negative(x: T) -> bool { x < 0 as T } diff --git a/src/libcore/uint-template/uint.rs b/src/libcore/uint-template/uint.rs index fc65d9a63e4..8954e5c4a67 100644 --- a/src/libcore/uint-template/uint.rs +++ b/src/libcore/uint-template/uint.rs @@ -61,8 +61,8 @@ pure fn div_round(x: uint, y: uint) -> uint { pure fn div_floor(x: uint, y: uint) -> uint { return x / y; } /// Produce a uint suitable for use in a hash table -pure fn hash(x: &uint) -> uint { - hash::hash_uint(*x) as uint +pure fn hash(x: uint) -> uint { + hash::hash_uint(x) as uint } /** diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 984092e9a58..2e93788e9ac 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1427,7 +1427,7 @@ impl<T: Eq> @[T]: Eq { pure fn lt<T: Ord>(a: &[T], b: &[T]) -> bool { let (a_len, b_len) = (a.len(), b.len()); - let mut end = uint::min(&a_len, &b_len); + let mut end = uint::min(a_len, b_len); let mut i = 0; while i < end { @@ -1841,7 +1841,7 @@ mod u8 { pure fn cmp(a: &~[u8], b: &~[u8]) -> int { let a_len = len(*a); let b_len = len(*b); - let n = uint::min(&a_len, &b_len) as libc::size_t; + let n = uint::min(a_len, b_len) as libc::size_t; let r = unsafe { libc::memcmp(unsafe::to_ptr(*a) as *libc::c_void, unsafe::to_ptr(*b) as *libc::c_void, n) as int |
