about summary refs log tree commit diff
path: root/src/libstd/num/strconv.rs
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2013-09-15 09:50:17 -0700
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2013-10-02 07:55:41 -0700
commitd9d1dfc1955fabb7ee3a55e9c84cdcd5aad67417 (patch)
tree44ee6031936df55eb8d34db48298b2a67b21cc3b /src/libstd/num/strconv.rs
parent17548378a707fae752dc722e2fb767a65195e422 (diff)
downloadrust-d9d1dfc1955fabb7ee3a55e9c84cdcd5aad67417.tar.gz
rust-d9d1dfc1955fabb7ee3a55e9c84cdcd5aad67417.zip
std: Replace num::IntConvertible with {To,From}Primitive
Diffstat (limited to 'src/libstd/num/strconv.rs')
-rw-r--r--src/libstd/num/strconv.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs
index 1863369fdf7..0f253a26ccf 100644
--- a/src/libstd/num/strconv.rs
+++ b/src/libstd/num/strconv.rs
@@ -140,7 +140,7 @@ pub fn int_to_str_bytes_common<T:NumCast+Zero+Eq+Ord+Integer+
     let _0: T = Zero::zero();
 
     let neg = num < _0;
-    let radix_gen: T = cast(radix);
+    let radix_gen: T = cast(radix).unwrap();
 
     let mut deccum = num;
     // This is just for integral types, the largest of which is a u64. The
@@ -163,7 +163,7 @@ pub fn int_to_str_bytes_common<T:NumCast+Zero+Eq+Ord+Integer+
         } else {
             current_digit_signed
         };
-        buf[cur] = match current_digit.to_u8() {
+        buf[cur] = match current_digit.to_u8().unwrap() {
             i @ 0..9 => '0' as u8 + i,
             i        => 'a' as u8 + (i - 10),
         };
@@ -247,7 +247,7 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
 
     let neg = num < _0 || (negative_zero && _1 / num == Float::neg_infinity());
     let mut buf: ~[u8] = ~[];
-    let radix_gen: T   = cast(radix as int);
+    let radix_gen: T   = cast(radix as int).unwrap();
 
     // First emit the non-fractional part, looping at least once to make
     // sure at least a `0` gets emitted.
@@ -265,7 +265,7 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
         deccum = deccum / radix_gen;
         deccum = deccum.trunc();
 
-        buf.push(char::from_digit(current_digit.to_int() as uint, radix)
+        buf.push(char::from_digit(current_digit.to_int().unwrap() as uint, radix)
              .unwrap() as u8);
 
         // No more digits to calculate for the non-fractional part -> break
@@ -322,7 +322,7 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Float+Round+
             let current_digit = deccum.trunc().abs();
 
             buf.push(char::from_digit(
-                current_digit.to_int() as uint, radix).unwrap() as u8);
+                current_digit.to_int().unwrap() as uint, radix).unwrap() as u8);
 
             // Decrease the deccumulator one fractional digit at a time
             deccum = deccum.fract();
@@ -492,7 +492,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
 
     let _0: T = Zero::zero();
     let _1: T = One::one();
-    let radix_gen: T = cast(radix as int);
+    let radix_gen: T = cast(radix as int).unwrap();
 
     let len = buf.len();
 
@@ -543,9 +543,9 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
 
                 // add/subtract current digit depending on sign
                 if accum_positive {
-                    accum = accum + cast(digit as int);
+                    accum = accum + cast(digit as int).unwrap();
                 } else {
-                    accum = accum - cast(digit as int);
+                    accum = accum - cast(digit as int).unwrap();
                 }
 
                 // Detect overflow by comparing to last value, except
@@ -556,11 +556,11 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
 
                     // Detect overflow by reversing the shift-and-add proccess
                     if accum_positive &&
-                        (last_accum != ((accum - cast(digit as int))/radix_gen.clone())) {
+                        (last_accum != ((accum - cast(digit as int).unwrap())/radix_gen.clone())) {
                         return NumStrConv::inf();
                     }
                     if !accum_positive &&
-                        (last_accum != ((accum + cast(digit as int))/radix_gen.clone())) {
+                        (last_accum != ((accum + cast(digit as int).unwrap())/radix_gen.clone())) {
                         return NumStrConv::neg_inf();
                     }
                 }
@@ -596,7 +596,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
                     // Decrease power one order of magnitude
                     power = power / radix_gen;
 
-                    let digit_t: T = cast(digit);
+                    let digit_t: T = cast(digit).unwrap();
 
                     // add/subtract current digit depending on sign
                     if accum_positive {
@@ -654,9 +654,9 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
         match exp {
             Some(exp_pow) => {
                 multiplier = if exp_pow < 0 {
-                    _1 / pow_with_uint::<T>(base, (-exp_pow.to_int()) as uint)
+                    _1 / pow_with_uint::<T>(base, (-exp_pow.to_int().unwrap()) as uint)
                 } else {
-                    pow_with_uint::<T>(base, exp_pow.to_int() as uint)
+                    pow_with_uint::<T>(base, exp_pow.to_int().unwrap() as uint)
                 }
             }
             None => return None // invalid exponent -> invalid number