Skip to content

to_map version of Params #4403

@kyrias

Description

@kyrias

Is your feature request related to a problem? Please describe.
It would be nice if there was a way to easily generate the query string for a given route based on the Params struct that view uses to deserialize the query string, to prevent both typos and accidentally using keys that might not exist, especially while refactoring.

Describe the solution you'd like
Either on Params or in a new trait matching it I'd like to have a to_map method returning a ParamsMap, the opposite of the Params::from_map method, which would then let the user call ParamsMap::to_query_string to build an appropriate query string for linking the user to.

Describe alternatives you've considered
Manually constructing the ParamsMap which is what I'm doing now, but it easily leads to mistakes that are only caught at runtime when exercising that code path.

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