[−][src]Trait yew_router_min::route::Switch
Derivable routing trait that allows instances of implementors to be constructed from Routes.
Note
Don't try to implement this yourself, rely on the derive macro.
Example
use yew_router_min::Switch; #[derive(Debug, Switch, PartialEq)] enum TestEnum { #[to = "/test/route"] TestRoute, #[to = "/capture/string/{path}"] CaptureString { path: String }, #[to = "/capture/number/{num}"] CaptureNumber { num: usize }, #[to = "/capture/unnamed/{doot}"] CaptureUnnamed(String), } assert_eq!( TestEnum::from_path("/test/route"), Some(TestEnum::TestRoute) ); assert_eq!( TestEnum::from_path("/capture/string/lorem"), Some(TestEnum::CaptureString { path: "lorem".to_string() }) ); assert_eq!( TestEnum::from_path("/capture/number/22"), Some(TestEnum::CaptureNumber { num: 22 }) ); assert_eq!( TestEnum::from_path("/capture/unnamed/lorem"), Some(TestEnum::CaptureUnnamed("lorem".to_string())) );
Required methods
Loading content...Provided methods
fn from_route(part: String) -> Option<Self>
Parses route.