From c0c8d3aa8fdd054372f91c997913b33146bdf9bd Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 29 Aug 2012 16:11:06 -0700 Subject: core: Demode int/uint mods --- src/libcore/int-template.rs | 12 ++++++++---- src/libcore/io.rs | 2 +- src/libcore/str.rs | 2 +- src/libcore/uint-template.rs | 12 ++++++++---- src/libcore/vec.rs | 4 ++-- 5 files changed, 20 insertions(+), 12 deletions(-) (limited to 'src/libcore') diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index 2f32376e715..ac4aceeaa95 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -1,3 +1,7 @@ +// NB: transitionary, de-mode-ing. +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; + import T = inst::T; import cmp::{Eq, Ord}; import num::from_int; @@ -21,8 +25,8 @@ 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 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 } @@ -155,7 +159,7 @@ fn parse_buf(buf: ~[u8], radix: uint) -> Option { } /// Parse a string to an int -fn from_str(s: ~str) -> Option { parse_buf(str::to_bytes(s), 10u) } +fn from_str(s: &str) -> Option { parse_buf(str::to_bytes(s), 10u) } /// Convert to a string in a given base fn to_str(n: T, radix: uint) -> ~str { @@ -235,7 +239,7 @@ fn test_to_str() { #[test] fn test_interfaces() { - fn test(ten: U) { + fn test(+ten: U) { assert (ten.to_int() == 10); let two: U = from_int(2); diff --git a/src/libcore/io.rs b/src/libcore/io.rs index d5521b509d4..1fd9b79ad9d 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -284,7 +284,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()), diff --git a/src/libcore/str.rs b/src/libcore/str.rs index b0cbf559fec..32665db7966 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -676,7 +676,7 @@ pure fn eq_slice(a: &str, b: &str) -> bool { let a_len = a.len(); let b_len = b.len(); if a_len != b_len { return false; } - let mut end = uint::min(a_len, b_len); + let mut end = uint::min(&a_len, &b_len); let mut i = 0u; while i < end { diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index e36d0744b2c..f95848f2496 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -1,3 +1,7 @@ +// NB: transitionary, de-mode-ing. +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; + import T = inst::T; import cmp::{Eq, Ord}; @@ -20,8 +24,8 @@ 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 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 } @@ -138,10 +142,10 @@ fn parse_buf(buf: &[const u8], radix: uint) -> Option { } /// Parse a string to an int -fn from_str(s: ~str) -> Option { parse_buf(str::to_bytes(s), 10u) } +fn from_str(s: &str) -> Option { parse_buf(str::to_bytes(s), 10u) } /// Parse a string as an unsigned integer. -fn from_str_radix(buf: ~str, radix: u64) -> Option { +fn from_str_radix(buf: &str, radix: u64) -> Option { if str::len(buf) == 0u { return None; } let mut i = str::len(buf) - 1u; let mut power = 1u64, n = 0u64; diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 33199576c11..ee82971c70e 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1430,7 +1430,7 @@ impl @[T]: Eq { pure fn lt(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 { @@ -1821,7 +1821,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 -- cgit 1.4.1-3-g733a5