diff options
| author | varkor <github@varkor.com> | 2018-02-15 15:54:40 +0000 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-02-19 14:53:30 +0000 |
| commit | c0e87f13a4d2f6fcef92c8c01bdc8dda9e0549a5 (patch) | |
| tree | 6ac9068dc63b83245c96964544f942bc8238eddb /src/libcore/num | |
| parent | 90759befe0234b20ecf81edbbff353b85419d7e9 (diff) | |
| download | rust-c0e87f13a4d2f6fcef92c8c01bdc8dda9e0549a5.tar.gz rust-c0e87f13a4d2f6fcef92c8c01bdc8dda9e0549a5.zip | |
Make ".e0" not parse as 0.0
This forces floats to have either a digit before the separating point, or after. Thus ".e0" is invalid like ".", when using `parse()`.
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/dec2flt/parse.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libcore/num/dec2flt/parse.rs b/src/libcore/num/dec2flt/parse.rs index d20986faa0f..69418434ebe 100644 --- a/src/libcore/num/dec2flt/parse.rs +++ b/src/libcore/num/dec2flt/parse.rs @@ -73,7 +73,8 @@ pub fn parse_decimal(s: &str) -> ParseResult { } Some(&b'.') => { let (fractional, s) = eat_digits(&s[1..]); - if integral.is_empty() && fractional.is_empty() && s.is_empty() { + if integral.is_empty() && fractional.is_empty() { + // We require at least a single digit before or after the point. return Invalid; } |
