about summary refs log tree commit diff
diff options
context:
space:
mode:
authorklensy <klensy@users.noreply.github.com>2021-02-19 18:47:22 +0300
committerklensy <klensy@users.noreply.github.com>2021-02-19 18:51:25 +0300
commitec09d7fc8bf28f52380cc7f90fb6ccf383c012ea (patch)
treefa20f627e2ec6cb68223dfd72d6481b48b6b3b4c
parent78e22069d018e83915201c8a218a0a94227f6420 (diff)
downloadrust-ec09d7fc8bf28f52380cc7f90fb6ccf383c012ea.tar.gz
rust-ec09d7fc8bf28f52380cc7f90fb6ccf383c012ea.zip
simplify eat_digits
-rw-r--r--library/core/src/num/dec2flt/parse.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/library/core/src/num/dec2flt/parse.rs b/library/core/src/num/dec2flt/parse.rs
index 2766843155a..858cc3c9b01 100644
--- a/library/core/src/num/dec2flt/parse.rs
+++ b/library/core/src/num/dec2flt/parse.rs
@@ -80,11 +80,8 @@ pub fn parse_decimal(s: &str) -> ParseResult<'_> {
 
 /// Carves off decimal digits up to the first non-digit character.
 fn eat_digits(s: &[u8]) -> (&[u8], &[u8]) {
-    let mut i = 0;
-    while i < s.len() && b'0' <= s[i] && s[i] <= b'9' {
-        i += 1;
-    }
-    (&s[..i], &s[i..])
+    let pos = s.iter().position(|c| !c.is_ascii_digit()).unwrap_or(s.len());
+    s.split_at(pos)
 }
 
 /// Exponent extraction and error checking.