Skip to content

Setters for Uri #1102

@jimmycuadra

Description

@jimmycuadra

I noticed hyper::Uri doesn't have any setter methods. It seems the only way to construct one is to parse it from a string or use Default.

I have a function that takes a Uri which is expected to have a scheme and authority, and adds path/query/fragment information to it. Currently, I'd have to do this by converting the input Uri to a string, manipulating it as a string, and then re-parsing it to a Uri. This seems error prone and involves fallible conversions, but if I was able to use a signature like this:

fn add_path_to_uri(uri: &mut Uri)

Then I'd be able to do statically-verifiable in-place modifications, like you can with the Url type from the url crate.

Would it be possible to add setters to the Uri type, or is there a reason it's so opaque?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions