1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 00:50:20 +02:00

allow primitive types for Path extractor

This commit is contained in:
Nikolay Kim
2018-03-31 17:12:08 -07:00
parent 23cfa649f4
commit 97e2bcd055
2 changed files with 108 additions and 24 deletions

View File

@@ -97,6 +97,14 @@ impl<'a, 'b, 'c: 'a> Index<&'b str> for &'c Params<'a> {
}
}
impl<'a, 'c: 'a> Index<usize> for &'c Params<'a> {
type Output = str;
fn index(&self, idx: usize) -> &str {
self.0[idx].1.as_ref()
}
}
/// Creates a `PathBuf` from a path parameter. The returned `PathBuf` is
/// percent-decoded. If a segment is equal to "..", the previous segment (if
/// any) is skipped.