From efc71a8bdb28fba88d0cc8916b33838bf43b3a8d Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Tue, 11 Jun 2013 13:10:37 +1000 Subject: std: unify the str -> [u8] functions as 3 methods: .as_bytes() and .as_bytes_with_null[_consume](). The first acts on &str and is not nul-terminated, the last two act on strings that are always null terminated (&'static str, ~str and @str). --- src/libstd/num/strconv.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/libstd/num/strconv.rs') diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 30efe9a3922..3905d82cd0f 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -16,6 +16,7 @@ use ops::{Add, Sub, Mul, Div, Rem, Neg}; use option::{None, Option, Some}; use char; use str; +use str::{StrSlice}; use kinds::Copy; use vec; use vec::{CopyableVector, ImmutableVector}; @@ -189,18 +190,18 @@ pub fn to_str_bytes_common (str::to_bytes("+inf"), true), - _ => (str::to_bytes("inf"), true) + SignAll => ("+inf".as_bytes().to_owned(), true), + _ => ("inf".as_bytes().to_owned(), true) } } else if is_neg_inf(num) { return match sign { - SignNone => (str::to_bytes("inf"), true), - _ => (str::to_bytes("-inf"), true), + SignNone => ("inf".as_bytes().to_owned(), true), + _ => ("-inf".as_bytes().to_owned(), true), } } @@ -638,7 +639,7 @@ pub fn from_str_common+Mul+ special: bool, exponent: ExponentFormat, empty_zero: bool, ignore_underscores: bool ) -> Option { - from_str_bytes_common(str::to_bytes(buf), radix, negative, + from_str_bytes_common(buf.as_bytes(), radix, negative, fractional, special, exponent, empty_zero, ignore_underscores) } -- cgit 1.4.1-3-g733a5