@@ -130,6 +130,13 @@ impl_NumStrConv_Integer!(u16)
130130impl_NumStrConv_Integer ! ( u32 )
131131impl_NumStrConv_Integer ! ( u64 )
132132
133+
134+ // Special value strings as [u8] consts.
135+ const inf_buf: [ u8 * 3 ] = [ 'i' as u8 , 'n' as u8 , 'f' as u8 ] ;
136+ const positive_inf_buf: [ u8 * 4 ] = [ '+' as u8 , 'i' as u8 , 'n' as u8 , 'f' as u8 ] ;
137+ const negative_inf_buf: [ u8 * 4 ] = [ '-' as u8 , 'i' as u8 , 'n' as u8 , 'f' as u8 ] ;
138+ const nan_buf: [ u8 * 3 ] = [ 'N' as u8 , 'a' as u8 , 'N' as u8 ] ;
139+
133140/**
134141 * Converts a number to its string representation as a byte vector.
135142 * 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>+
479486 }
480487
481488 if special {
482- if buf == str :: inf_buf || buf == str :: positive_inf_buf {
489+ if buf == inf_buf || buf == positive_inf_buf {
483490 return NumStrConv :: inf ( ) ;
484- } else if buf == str :: negative_inf_buf {
491+ } else if buf == negative_inf_buf {
485492 if negative {
486493 return NumStrConv :: neg_inf ( ) ;
487494 } else {
488495 return None ;
489496 }
490- } else if buf == str :: nan_buf {
497+ } else if buf == nan_buf {
491498 return NumStrConv :: NaN ( ) ;
492499 }
493500 }
0 commit comments