Skip to content

[Percent encoding] [Question] Do the percent encoding functions really need 'static AsciiSets? #1043

Open
@Scripter17

Description

@Scripter17

Currently, percent_encode and utf8_percent_encode require the AsciiSet to be 'static, despite already having a lifetime bound 'a on the input string.

This is very rarely an issue, but as part of a URL cleaning tool I'm making I allow users to choose various common AsciiSets from the URL spec and javascript. The API I've designed is an enum of names corresponding to those AsciiSets. For flexibility I'm considering adding a Custom(#[serde(some_glue_stuff)] AsciiSet) to allow users with niche cases to not have to bodge stuff. This would require the getter function to go from get(&self) -> &'static AsciiSet to get<'a>(&'a self) -> &'a AsciiSet, which would make it incompatible with the percent_encode and utf8_percent_encode functions.

Fortunately the cases where this is needed are rare and perfectly fine for me to just upstream with a new name (which also avoids bloating the enum from 1 byte to 17 bytes), so it's not a big deal if the functions can't be changed to accept &'a AsciiSets. It's just not clear to me if or why they can't.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions