Add to_route() to Switch trait.
hgzimmerman opened this issue · 1 comments
Is your feature request related to a problem? Please describe.
It would be nice to convert an item that implements Switch into a Route. This way, handling naked Strings won't be required at all when using the router.
Describe the solution you'd like
Switch could gain a to_route_builder()
method.
This may create a new RouteBuilder
type that works with &str
instead of String
to avoid excess allocations, and finalizing it will create a Route
.
A ToRoute
trait might be added as well, denoting all types that can be converted to a Route. Similarly, extraction from Strings into Routes might require breaking off from the current Switch trait, and delegating that to another trait (TryFrom<&str>
??).
Avoiding every primitive that currently implements Switch getting to_route()
might make sense as well, because you need to have leading slashes for any of the routes to make sense (you wouldn't want a String to turn itself into a Route, because the resulting item won't have a leading slash).
closed via: #108