1fn main() -> Result<(), Box<dyn std::error::Error>> {
2 let router = reset_recognizer::Router::build()
3 .add(r"^/posts/(\d+)/comments/(\d+)$", "comment".to_string())
4 .add(r"^/posts/(\d+)/comments$", "comments".to_string())
5 .add(r"^/posts/(\d+)$", "post".to_string())
6 .add(r"^/posts$", "posts".to_string())
7 .add(r"^/comments$", "comments2".to_string())
8 .add(r"^/comments/(\d+)$", "comment2".to_string())
9 .add_with_priority(r"^/(.+)$", -1, "not_found".to_string())
10 .finish()?;
11
12 let matched = router.recognize("/posts/100/comments/200")?;
13
14 let (post_id, comment_id) = matched.captures.parsed::<(i32, i32)>()?;
15
16 std::thread::spawn(move || {
17 println!("{:?}", (&post_id, &comment_id));
18 }).join().unwrap();
19
20
21
22 Ok(())
23}