@@ -130,6 +130,13 @@ impl_NumStrConv_Integer!(u16)
130
130
impl_NumStrConv_Integer ! ( u32 )
131
131
impl_NumStrConv_Integer ! ( u64 )
132
132
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
+
133
140
/**
134
141
* Converts a number to its string representation as a byte vector.
135
142
* 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>+
479
486
}
480
487
481
488
if special {
482
- if buf == str :: inf_buf || buf == str :: positive_inf_buf {
489
+ if buf == inf_buf || buf == positive_inf_buf {
483
490
return NumStrConv :: inf ( ) ;
484
- } else if buf == str :: negative_inf_buf {
491
+ } else if buf == negative_inf_buf {
485
492
if negative {
486
493
return NumStrConv :: neg_inf ( ) ;
487
494
} else {
488
495
return None ;
489
496
}
490
- } else if buf == str :: nan_buf {
497
+ } else if buf == nan_buf {
491
498
return NumStrConv :: NaN ( ) ;
492
499
}
493
500
}
0 commit comments