Function std::num::strconv::from_str_bytes_common[src]
pub fn from_str_bytes_common<T: NumCast + Zero + One + PartialEq + PartialOrd + Div<T, T> + Mul<T, T> + Sub<T, T> + Neg<T> + Add<T, T> + NumStrConv + Clone>(buf: &[u8], radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool, ignore_underscores: bool) -> Option<T>
Parses a byte slice as a number. This is meant to
be a common base implementation for all numeric string conversion
functions like from_str() or from_str_radix().
Arguments
buf- The byte slice to parse.radix- Which base to parse the number as. Accepts 2-36.negative- Whether to accept negative numbers.fractional- Whether to accept numbers with fractional parts.special- Whether to accept special values likeinfandNaN. Can conflict withradix, see Failure.exponent- Which exponent format to accept. Options are:ExpNone: No Exponent, accepts just plain numbers like42or-8.2.ExpDec: Accepts numbers with a decimal exponent like42e5or8.2E-2. The exponent string itself is always base 10. Can conflict withradix, see Failure.ExpBin: Accepts numbers with a binary exponent like42P-8orFFp128. The exponent string itself is always base 10. Can conflict withradix, see Failure.
empty_zero- Whether to accept an emptybufas a 0 or not.ignore_underscores- Whether all underscores within the string should be ignored.
Return value
Returns Some(n) if buf parses to a number n without overflowing, and
None otherwise, depending on the constraints set by the remaining
arguments.
Failure
- Fails if
radix< 2 orradix> 36. - Fails if
radix> 14 andexponentisExpDecdue to conflict between digit and exponent sign'e'. - Fails if
radix> 25 andexponentisExpBindue to conflict between digit and exponent sign'p'. - Fails if
radix> 18 andspecial == truedue to conflict between digit and lowest first character ininfandNaN, the'i'.