route
function · ferroui-view · v0.5.0
fn route(pattern: &str, view: impl Fn(&RouteMatch) -> crate::element::Element + 'static) -> RouteDef
A route: a pattern of segments separated by /, where :name matches one
segment and binds it to the parameter name, * matches the rest of the
path (and comes last), and any other segment matches itself. view makes
the element of the route from what the pattern matched.
route("/", |_| rsx! { Home {} })
route("/people/:id", |m| rsx! { Person { id: m.param("id").unwrap_or_default().to_string() } })
route("*", |m| rsx! { TextBlock { text: format!("Nothing at {}", m.path()) } })
Panics
When a segment follows *.
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.