rust/library/alloc
Matthias Krüger 50327d2c91
Rollup merge of #89825 - martinvonz:split-inclusive-empty, r=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).

Closes #89716.
2021-12-14 20:47:26 +01:00
..
benches Add #[must_use] to remaining alloc functions 2021-10-15 11:46:49 -04:00
src Rollup merge of #91529 - TennyZhuang:try_reserve_binary_heap, r=yaahc 2021-12-14 10:21:02 +01:00
tests Rollup merge of #89825 - martinvonz:split-inclusive-empty, r=m-ou-se 2021-12-14 20:47:26 +01:00
Cargo.toml rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00