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 /src/libcore/num | |
| parent | 51eb7dc8a719f6ae05a563109b3bbccee319263e (diff) | |
| download | rust-624a685283f66afcb40ee3c235624aedebc2f08f.tar.gz rust-624a685283f66afcb40ee3c235624aedebc2f08f.zip | |
Moved float str buffer constants to the strconv module
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/strconv.rs | 13 |
1 files changed, 10 insertions, 3 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(); } } |
