You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
…=m-ou-se
Make split_inclusive() on an empty slice yield an empty output
`[].split_inclusive()` currently yields a single, empty slice. That's
different from `"".split_inslusive()`, which yields no output at
all. I think that makes the slice version harder to use.
The case where I ran into this bug was when writing code for
generating a diff between two slices of bytes. I wanted to prefix
removed lines with "-" and a added lines with "+". Due to
`split_inclusive()`'s current behavior, that means that my code prints
just a "-" or "+" for empty files. I suspect most existing callers
have similar "bugs" (which would be fixed by this patch).
Closesrust-lang#89716.
I tried this code:
I expected to see this happen: Both assertions pass, i.e.
split_inclusive()
yields no results on empty input.Instead, this happened: The second assertion fails because
split_inclusive()
on an empty slice yields a single empty element instead of no elements.Meta
rustc --version --verbose
:(Skipping backtrace from template as that doesn't seem relevant.)
The text was updated successfully, but these errors were encountered: