diff options
| author | Richo Healey <richo@psych0tik.net> | 2014-06-21 03:39:03 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2014-07-08 13:01:43 -0700 |
| commit | 12c334a77b897f7b1cb6cff3c56a71ecb89c82af (patch) | |
| tree | 1f5a85061a69058875391ec6171cf8b446996dff /src/libstd/num | |
| parent | bfe4ddfdea45533c98657701509bb7185fd96cba (diff) | |
| download | rust-12c334a77b897f7b1cb6cff3c56a71ecb89c82af.tar.gz rust-12c334a77b897f7b1cb6cff3c56a71ecb89c82af.zip | |
std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.
[breaking-change]
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/f32.rs | 2 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 2 | ||||
| -rw-r--r-- | src/libstd/num/int_macros.rs | 20 | ||||
| -rw-r--r-- | src/libstd/num/strconv.rs | 8 | ||||
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 20 |
5 files changed, 26 insertions, 26 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 2b2ffb9f4e2..680620f5a75 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -245,7 +245,7 @@ impl FloatMath for f32 { /// /// * num - The float value #[inline] -pub fn to_str(num: f32) -> String { +pub fn to_string(num: f32) -> String { let (r, _) = strconv::float_to_str_common( num, 10u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false); r diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index e156d2ce553..3180ee28c6f 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -253,7 +253,7 @@ impl FloatMath for f64 { /// /// * num - The float value #[inline] -pub fn to_str(num: f64) -> String { +pub fn to_string(num: f64) -> String { let (r, _) = strconv::float_to_str_common( num, 10u, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false); r diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index a4200b55a59..3c01edf2339 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -55,7 +55,7 @@ impl FromStrRadix for $T { /// Convert to a string as a byte slice in a given base. /// -/// Use in place of x.to_str() when you do not need to store the string permanently +/// Use in place of x.to_string() when you do not need to store the string permanently /// /// # Examples /// @@ -143,7 +143,7 @@ mod tests { } #[test] - fn test_to_str() { + fn test_to_string() { assert_eq!((0 as $T).to_str_radix(10u), "0".to_string()); assert_eq!((1 as $T).to_str_radix(10u), "1".to_string()); assert_eq!((-1 as $T).to_str_radix(10u), "-1".to_string()); @@ -155,28 +155,28 @@ mod tests { #[test] fn test_int_to_str_overflow() { let mut i8_val: i8 = 127_i8; - assert_eq!(i8_val.to_str(), "127".to_string()); + assert_eq!(i8_val.to_string(), "127".to_string()); i8_val += 1 as i8; - assert_eq!(i8_val.to_str(), "-128".to_string()); + assert_eq!(i8_val.to_string(), "-128".to_string()); let mut i16_val: i16 = 32_767_i16; - assert_eq!(i16_val.to_str(), "32767".to_string()); + assert_eq!(i16_val.to_string(), "32767".to_string()); i16_val += 1 as i16; - assert_eq!(i16_val.to_str(), "-32768".to_string()); + assert_eq!(i16_val.to_string(), "-32768".to_string()); let mut i32_val: i32 = 2_147_483_647_i32; - assert_eq!(i32_val.to_str(), "2147483647".to_string()); + assert_eq!(i32_val.to_string(), "2147483647".to_string()); i32_val += 1 as i32; - assert_eq!(i32_val.to_str(), "-2147483648".to_string()); + assert_eq!(i32_val.to_string(), "-2147483648".to_string()); let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; - assert_eq!(i64_val.to_str(), "9223372036854775807".to_string()); + assert_eq!(i64_val.to_string(), "9223372036854775807".to_string()); i64_val += 1 as i64; - assert_eq!(i64_val.to_str(), "-9223372036854775808".to_string()); + assert_eq!(i64_val.to_string(), "-9223372036854775808".to_string()); } #[test] diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 5028987f44f..88fc6e1ffd8 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -146,7 +146,7 @@ static NAN_BUF: [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8]; /** * Converts an integral number to its string representation as a byte vector. * This is meant to be a common base implementation for all integral string - * conversion functions like `to_str()` or `to_str_radix()`. + * conversion functions like `to_string()` or `to_str_radix()`. * * # Arguments * - `num` - The number to convert. Accepts any number that @@ -226,7 +226,7 @@ pub fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f: /** * Converts a number to its string representation as a byte vector. * This is meant to be a common base implementation for all numeric string - * conversion functions like `to_str()` or `to_str_radix()`. + * conversion functions like `to_string()` or `to_str_radix()`. * * # Arguments * - `num` - The number to convert. Accepts any number that @@ -894,9 +894,9 @@ mod bench { use f64; #[bench] - fn float_to_str(b: &mut Bencher) { + fn float_to_string(b: &mut Bencher) { let mut rng = weak_rng(); - b.iter(|| { f64::to_str(rng.gen()); }) + b.iter(|| { f64::to_string(rng.gen()); }) } } } diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 7f2efe034a2..cfcaf0fa8da 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -56,7 +56,7 @@ impl FromStrRadix for $T { /// Convert to a string as a byte slice in a given base. /// -/// Use in place of x.to_str() when you do not need to store the string permanently +/// Use in place of x.to_string() when you do not need to store the string permanently /// /// # Examples /// @@ -101,7 +101,7 @@ mod tests { use u16; #[test] - pub fn test_to_str() { + pub fn test_to_string() { assert_eq!((0 as $T).to_str_radix(10u), "0".to_string()); assert_eq!((1 as $T).to_str_radix(10u), "1".to_string()); assert_eq!((2 as $T).to_str_radix(10u), "2".to_string()); @@ -141,28 +141,28 @@ mod tests { #[test] fn test_uint_to_str_overflow() { let mut u8_val: u8 = 255_u8; - assert_eq!(u8_val.to_str(), "255".to_string()); + assert_eq!(u8_val.to_string(), "255".to_string()); u8_val += 1 as u8; - assert_eq!(u8_val.to_str(), "0".to_string()); + assert_eq!(u8_val.to_string(), "0".to_string()); let mut u16_val: u16 = 65_535_u16; - assert_eq!(u16_val.to_str(), "65535".to_string()); + assert_eq!(u16_val.to_string(), "65535".to_string()); u16_val += 1 as u16; - assert_eq!(u16_val.to_str(), "0".to_string()); + assert_eq!(u16_val.to_string(), "0".to_string()); let mut u32_val: u32 = 4_294_967_295_u32; - assert_eq!(u32_val.to_str(), "4294967295".to_string()); + assert_eq!(u32_val.to_string(), "4294967295".to_string()); u32_val += 1 as u32; - assert_eq!(u32_val.to_str(), "0".to_string()); + assert_eq!(u32_val.to_string(), "0".to_string()); let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; - assert_eq!(u64_val.to_str(), "18446744073709551615".to_string()); + assert_eq!(u64_val.to_string(), "18446744073709551615".to_string()); u64_val += 1 as u64; - assert_eq!(u64_val.to_str(), "0".to_string()); + assert_eq!(u64_val.to_string(), "0".to_string()); } #[test] |
