diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-06-30 10:39:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-30 10:39:47 +0200 |
| commit | fe1f83ccd7d0e20f3e22a9c106dd68a2bfa2b944 (patch) | |
| tree | ec04c79d4299af4a1efd4f0239cb16b3855852b3 | |
| parent | c7aee65eddab5ff36538a6959689a0e27d6e21e5 (diff) | |
| parent | 39bf1dcce5b0e80fbdbcde30e618821f5c9b0bf0 (diff) | |
| download | rust-fe1f83ccd7d0e20f3e22a9c106dd68a2bfa2b944.tar.gz rust-fe1f83ccd7d0e20f3e22a9c106dd68a2bfa2b944.zip | |
Rollup merge of #126906 - GrigorenkoPV:fixme-split_at_first, r=Mark-Simulacrum
Small fixme in core now that split_first has no codegen issues https://github.com/rust-lang/rust/issues/109328#issuecomment-1677366881 BTW, I have a crate implementing exactly this kind of an iterator: https://github.com/GrigorenkoPV/head-tail-iter and I was wondering if it would be worthwhile to try and make an ACP for it to get it included in std (or maybe itertools). My only doubt is that it kinda incentives writing O(n^2) algorithms and is not the hard to replace with a `while let` loop (just as in this PR).
| -rw-r--r-- | library/core/src/num/dec2flt/common.rs | 4 | ||||
| -rw-r--r-- | library/core/src/num/dec2flt/parse.rs | 4 |
2 files changed, 2 insertions, 6 deletions
diff --git a/library/core/src/num/dec2flt/common.rs b/library/core/src/num/dec2flt/common.rs index 11a62648519..c85727b4938 100644 --- a/library/core/src/num/dec2flt/common.rs +++ b/library/core/src/num/dec2flt/common.rs @@ -39,9 +39,7 @@ impl ByteSlice for [u8] { fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self { let mut s = self; - // FIXME: Can't use s.split_first() here yet, - // see https://github.com/rust-lang/rust/issues/109328 - while let [c, s_next @ ..] = s { + while let Some((c, s_next)) = s.split_first() { let c = c.wrapping_sub(b'0'); if c < 10 { func(c); diff --git a/library/core/src/num/dec2flt/parse.rs b/library/core/src/num/dec2flt/parse.rs index b0a23835c5b..975bb8ad6bc 100644 --- a/library/core/src/num/dec2flt/parse.rs +++ b/library/core/src/num/dec2flt/parse.rs @@ -51,9 +51,7 @@ fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) { let mut s = *s_ref; while *x < MIN_19DIGIT_INT { - // FIXME: Can't use s.split_first() here yet, - // see https://github.com/rust-lang/rust/issues/109328 - if let [c, s_next @ ..] = s { + if let Some((c, s_next)) = s.split_first() { let digit = c.wrapping_sub(b'0'); if digit < 10 { |
