Support wildcards in typed paths (#1003)

* Support wildcards in typed paths

* changelog
This commit is contained in:
David Pedersen
2022-05-06 13:05:30 +02:00
committed by GitHub
parent 4ff78e552d
commit b5183afbec
6 changed files with 20 additions and 20 deletions
+4 -8
View File
@@ -297,14 +297,10 @@ fn parse_path(path: &LitStr) -> syn::Result<Vec<Segment>> {
path.value()
.split('/')
.map(|segment| {
if segment.contains('*') {
return Err(syn::Error::new_spanned(
path,
"`typed_path` cannot contain wildcards",
));
}
if let Some(capture) = segment.strip_prefix(':') {
if let Some(capture) = segment
.strip_prefix(':')
.or_else(|| segment.strip_prefix('*'))
{
Ok(Segment::Capture(capture.to_owned(), path.span()))
} else {
Ok(Segment::Static(segment.to_owned()))