Skip to content

Uri::path() and and Uri::path_and_query() have confusing semantics #176

Open
@briansmith

Description

@briansmith

path() returns &str which means it is never missing. Then why does path_and_query() return Option<&str> instead of &str? In other words, if the path is never missing then how can path_and_query() ever be missing? Under what circumstances would path_and_query() return None?

path() returns * when the URI is *. This seems really error prone. Regardless, what does path_and_query() return when path() returns *? This should be documented.

I would expect that url.path_and_query().unwrap().starts_with(url.path()) never panics and is always true, and that url.path_and_query().unwrap() == url.path() + url.query().map(|q| "?" + q) never panics and is always true. That is, I would expect that url.path_and_query() never returns None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-uriArea: Uri and partsB-rfcBlocked: request for comments. More discussion would help move this along.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions