Skip to content

add ends_with_ignore_ascii_case str (search) utility #801

@GlenDC

Description

@GlenDC

It can probably be something like this:

fn ends_with_ignore_ascii_case(path: &str, suffix: &str) -> bool {
    if path.len() < suffix.len() {
        return false;
    }

    let start = path.len() - suffix.len();
    path.get(start..)
        .is_some_and(|tail| tail.eq_ignore_ascii_case(suffix))
}

We already have starts_with_ignore_ascii_case, from which that was ported.
Put it in the same module as that function

Also add sufficient test cases similar to the starts_with version.

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomersmentor availableA mentor is available to help you through the issue.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions