Skip to content

split() should document the behavior around adjacent separators, particularly at the start of the string #25986

Closed
@nikomatsakis

Description

@nikomatsakis

It's not clear to me if this is the expected behavior or not, but this program:

fn main() {
    let x = "    a  b c".to_string();
    let d: Vec<_> = x.split(' ').collect();
    println!("{:?}", d);
}

yields:

["", "", "", "", "a", "", "b", "c"]

whereas I expected:

["a","b","c"]

If the current behavior is expected, it should be more clearly documented, at minimum.

cc @Kimundi

Metadata

Metadata

Assignees

No one assigned

    Labels

    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