rust/library/core/src/str
bors 598e29bf70 Auto merge of #100806 - timvermeulen:split_inclusive_double_ended_bound, r=dtolnay
Fix generic bound of `str::SplitInclusive`'s `DoubleEndedIterator` impl

`str::SplitInclusive`'s `DoubleEndedIterator` implementation currently uses a `ReverseSearcher` bound for the corresponding searcher. A `DoubleEndedSearcher` bound should have been used instead.

`DoubleEndedIterator` requires that repeated `next_back` calls produce the same items as repeated `next` calls, in opposite order. `ReverseSearcher` lets you search starting from the back of a string, but it makes no guarantees about how its matches correspond to the matches found by a forward search. `DoubleEndedSearcher` is a subtrait of `ReverseSearcher` and does require that the same matches are found in both directions.

This bug fix is a breaking change. Calling `next_back` on `"a+++b".split_inclusive("++")` is currently accepted with repeated calls producing `"b"` and `"a+++"`, while forward iteration yields `"a++"` and `"+b"`. Also see https://github.com/rust-lang/rust/issues/100756#issuecomment-1221307166 for more details.

I believe that this is the only iterator that uses this bound incorrectly — other related iterators such as `str::Split` do have a `DoubleEndedSearcher` bound for their `DoubleEndedIterator` implementation. And `slice::SplitInclusive` doesn't face this problem at all because it doesn't use patterns, only a predicate.

cc `@SkiFire13`
2023-10-07 17:10:02 +00:00
..
converts.rs Add invalid_from_utf8 analogous to invalid_from_utf8_unchecked 2023-05-27 00:18:28 +02:00
count.rs Make some usize-typed masks definition agnostic to the size of usize 2022-04-15 17:04:59 +02:00
error.rs remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
iter.rs Auto merge of #100806 - timvermeulen:split_inclusive_double_ended_bound, r=dtolnay 2023-10-07 17:10:02 +00:00
lossy.rs Expose Utf8Lossy as Utf8Chunks 2022-08-20 12:49:20 -04:00
mod.rs Rollup merge of #115454 - vwkd:patch-1, r=scottmcm 2023-10-06 13:18:33 +02:00
pattern.rs Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
traits.rs Add more diagnostic items for clippy 2023-10-05 18:21:47 -04:00
validations.rs Replace most uses of pointer::offset with add and sub 2022-08-21 02:21:41 +04:00