Commit 1371bd3
authored
Switch from route-recognizer to matchit (#4096)
* feat(yew-router)!: switch from route-recognizer to matchit
Migrate `yew-router` from the unmaintained `route-recognizer` crate to
`matchit`, aligning route parameter syntax with Axum and the broader
Rust ecosystem (`:param` → `{param}`, `*wildcard` → `{*wildcard}`).
* fix(yew-router): include route pattern and error in build_router panic
matchit has stricter conflict detection than route-recognizer, so
users migrating with ambiguous routes (e.g. `/{id}` and `/{name}`)
will hit this panic. The old message ("failed to insert route") gave
no indication of which route or why; now it shows both.
* fix(yew-router-macro): reject route params without corresponding fields
A unit variant like `Settings` with `#[at("/settings/{*_rest}")]`
compiled but produced a broken `to_path()` that returned the literal
pattern string. This was a pre-existing bug (same with the old
`*rest` syntax) now caught at compile time.
Also fixes the nested-router docs examples to use named fields.
* fix(yew-router-macro): reject old `:param` and `*param` route syntax
Under matchit, the old route-recognizer syntax silently becomes literal
path segments, causing routes to never match. Emit a compile-time error
with a suggested fix instead.1 parent 13841df commit 1371bd3
23 files changed
Lines changed: 263 additions & 71 deletions
File tree
- examples
- function_router/src
- router/src
- wasi_ssr_module/src
- packages
- yew-router-macro
- src
- tests/routable_derive
- yew-router
- src
- tests
- website
- docs/concepts
- i18n
- ja/docusaurus-plugin-content-docs/current/concepts
- zh-Hans/docusaurus-plugin-content-docs/current/concepts
- zh-Hant/docusaurus-plugin-content-docs/current/concepts
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
11 | 30 | | |
12 | 31 | | |
13 | 32 | | |
| |||
101 | 120 | | |
102 | 121 | | |
103 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
104 | 172 | | |
105 | 173 | | |
106 | 174 | | |
| |||
174 | 242 | | |
175 | 243 | | |
176 | 244 | | |
177 | | - | |
| 245 | + | |
178 | 246 | | |
179 | 247 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
185 | 252 | | |
186 | 253 | | |
187 | 254 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments