diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2013-03-22 02:04:13 +0100 |
|---|---|---|
| committer | Marvin Löbel <loebel.marvin@gmail.com> | 2013-03-26 14:59:17 +0100 |
| commit | 624a685283f66afcb40ee3c235624aedebc2f08f (patch) | |
| tree | dc110ba3ff7af4a215e78041aff5cc9185a54f54 | |
| parent | 51eb7dc8a719f6ae05a563109b3bbccee319263e (diff) | |
| download | rust-624a685283f66afcb40ee3c235624aedebc2f08f.tar.gz rust-624a685283f66afcb40ee3c235624aedebc2f08f.zip | |
Moved float str buffer constants to the strconv module
| -rw-r--r-- | src/libcore/num/strconv.rs | 13 | ||||
| -rw-r--r-- | src/libcore/str.rs | 8 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs index 26f0582bfb2..e73a4a2ccaa 100644 --- a/src/libcore/num/strconv.rs +++ b/src/libcore/num/strconv.rs @@ -130,6 +130,13 @@ impl_NumStrConv_Integer!(u16) impl_NumStrConv_Integer!(u32) impl_NumStrConv_Integer!(u64) + +// Special value strings as [u8] consts. +const inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8]; +const positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8, 'n' as u8, 'f' as u8]; +const negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8, 'n' as u8, 'f' as u8]; +const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8]; + /** * Converts a number to its string representation as a byte vector. * This is meant to be a common base implementation for all numeric string @@ -479,15 +486,15 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+ } if special { - if buf == str::inf_buf || buf == str::positive_inf_buf { + if buf == inf_buf || buf == positive_inf_buf { return NumStrConv::inf(); - } else if buf == str::negative_inf_buf { + } else if buf == negative_inf_buf { if negative { return NumStrConv::neg_inf(); } else { return None; } - } else if buf == str::nan_buf { + } else if buf == nan_buf { return NumStrConv::NaN(); } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 92358c6a5e9..e91120e7790 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1919,14 +1919,6 @@ static tag_five_b: uint = 248u; static max_five_b: uint = 67108864u; static tag_six_b: uint = 252u; -// Constants used for converting strs to floats -pub static inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8]; -pub static positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8, - 'n' as u8, 'f' as u8]; -pub static negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8, - 'n' as u8, 'f' as u8]; -pub static nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8]; - /** * Work with the byte buffer of a string. * |
