Routable improvements (#1461)
* Fix `SegmentType::CatchAll` `Display` * Rename `display_route_segements` to `display_route_segments` and add dots to docs * Fix `Routeable::static_routes` and add more route retrieval methods * Fix Clippy and extract duplication to function * Return route strings instead of instances * Remove some methods * Clippy
This commit is contained in:
1 parent
300cbf4fc6
commit
ae5dca8f43
3 files changed
+91
-69
No files matched your search
@@ -210,7 +210,7 @@ pub fn routable(input: TokenStream) -> TokenStream {
|
||||
let display_impl = route_enum.impl_display();
|
||||
let routable_impl = route_enum.routable_impl();
|
||||
|
||||
quote! {
|
||||
(quote! {
|
||||
#error_type
|
||||
|
||||
#display_impl
|
||||
@@ -218,7 +218,7 @@ pub fn routable(input: TokenStream) -> TokenStream {
|
||||
#routable_impl
|
||||
|
||||
#parse_impl
|
||||
}
|
||||
})
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -678,9 +678,9 @@ impl ToTokens for SegmentType {
|
||||
impl<'a> From<&'a RouteSegment> for SegmentType {
|
||||
fn from(value: &'a RouteSegment) -> Self {
|
||||
match value {
|
||||
segment::RouteSegment::Static(s) => SegmentType::Static(s.to_string()),
|
||||
segment::RouteSegment::Dynamic(s, _) => SegmentType::Dynamic(s.to_string()),
|
||||
segment::RouteSegment::CatchAll(s, _) => SegmentType::CatchAll(s.to_string()),
|
||||
RouteSegment::Static(s) => SegmentType::Static(s.to_string()),
|
||||
RouteSegment::Dynamic(s, _) => SegmentType::Dynamic(s.to_string()),
|
||||
RouteSegment::CatchAll(s, _) => SegmentType::CatchAll(s.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ impl RouteSegment {
|
||||
match self {
|
||||
Self::Static(segment) => quote! { write!(f, "/{}", #segment)?; },
|
||||
Self::Dynamic(ident, _) => quote! { write!(f, "/{}", #ident)?; },
|
||||
Self::CatchAll(ident, _) => quote! { #ident.display_route_segements(f)?; },
|
||||
Self::CatchAll(ident, _) => quote! { #ident.display_route_segments(f)?; },
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user