Skip to content

split_inclusive's DoubleEndedIterator implementation is unexpected #100756

Open
@robertbastian

Description

@robertbastian

I would expect next_back() to include the separator before the string, i.e. the separator that separates the item from the next one. However:

"a+b+c".split_inclusive('+').collect::<Vec<_>>()
// => vec!["a+", "b+", "c"]
"a+b+c".split_inclusive('+').rev().collect::<Vec<_>>()
// => vec!["c", "b+", "a+"], but I'd expect vec!["+c", "+b", "a"]

Playground

If this behaviour is intended, it should be documented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.T-libsRelevant to the library team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions