mirror of
https://github.com/rust-lang/rust
synced 2024-10-01 14:25:08 +00:00
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).
This commit is contained in:
commit
fe1f83ccd7
|
@ -39,9 +39,7 @@ fn offset_from(&self, other: &Self) -> isize {
|
||||||
fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
|
fn parse_digits(&self, mut func: impl FnMut(u8)) -> &Self {
|
||||||
let mut s = self;
|
let mut s = self;
|
||||||
|
|
||||||
// FIXME: Can't use s.split_first() here yet,
|
while let Some((c, s_next)) = s.split_first() {
|
||||||
// see https://github.com/rust-lang/rust/issues/109328
|
|
||||||
while let [c, s_next @ ..] = s {
|
|
||||||
let c = c.wrapping_sub(b'0');
|
let c = c.wrapping_sub(b'0');
|
||||||
if c < 10 {
|
if c < 10 {
|
||||||
func(c);
|
func(c);
|
||||||
|
|
|
@ -51,9 +51,7 @@ fn try_parse_19digits(s_ref: &mut &[u8], x: &mut u64) {
|
||||||
let mut s = *s_ref;
|
let mut s = *s_ref;
|
||||||
|
|
||||||
while *x < MIN_19DIGIT_INT {
|
while *x < MIN_19DIGIT_INT {
|
||||||
// FIXME: Can't use s.split_first() here yet,
|
if let Some((c, s_next)) = s.split_first() {
|
||||||
// see https://github.com/rust-lang/rust/issues/109328
|
|
||||||
if let [c, s_next @ ..] = s {
|
|
||||||
let digit = c.wrapping_sub(b'0');
|
let digit = c.wrapping_sub(b'0');
|
||||||
|
|
||||||
if digit < 10 {
|
if digit < 10 {
|
||||||
|
|
Loading…
Reference in a new issue