@@ -6,9 +6,14 @@ use std::{convert::Into, fmt, str::FromStr};
66use log:: info;
77use serde:: { Deserialize , Serialize } ;
88use smart_default:: SmartDefault ;
9- use stdweb:: { __js_serializable_boilerplate, js_deserializable, js_serializable} ;
9+ use stdweb:: {
10+ __js_serializable_boilerplate, js_deserializable, js_serializable,
11+ } ;
1012use web_logger;
11- use yew:: { html, Bridge , Bridged , Component , ComponentLink , Html , Renderable , ShouldRender } ;
13+ use yew:: {
14+ html, Bridge , Bridged , Component , ComponentLink , Html , Renderable ,
15+ ShouldRender ,
16+ } ;
1217use yew_router:: { Route , RouterAgent } ;
1318
1419#[ derive( SmartDefault , Debug , Clone , PartialEq , Serialize , Deserialize ) ]
@@ -43,11 +48,17 @@ impl fmt::Display for RouterTarget {
4348 match self {
4449 RouterTarget :: Home => "home" . into( ) ,
4550 RouterTarget :: Feed => "feed" . into( ) ,
46- RouterTarget :: Profile { user_id } => format!( "profile/{}" , user_id) ,
47- RouterTarget :: Foo { name, id } => format!( "foo/{}/{}" , name, id) ,
51+ RouterTarget :: Profile { user_id } => {
52+ format!( "profile/{}" , user_id)
53+ }
54+ RouterTarget :: Foo { name, id } => {
55+ format!( "foo/{}/{}" , name, id)
56+ }
4857 RouterTarget :: Post ( i) => format!( "post/{}" , i) ,
4958 RouterTarget :: Bar ( s, i) => format!( "bar/{}/{}" , s, i) ,
50- RouterTarget :: Settings ( sub_route) => format!( "settings/{}" , sub_route) ,
59+ RouterTarget :: Settings ( sub_route) => {
60+ format!( "settings/{}" , sub_route)
61+ }
5162 } ,
5263 )
5364 }
@@ -82,8 +93,12 @@ impl FromStr for RouterTarget {
8293 id : parse ( id) ?,
8394 } ,
8495 [ "post" , id] => RouterTarget :: Post ( parse ( id) ?) ,
85- [ "bar" , name, id] => RouterTarget :: Bar ( name. to_string ( ) , parse ( id) ?) ,
86- [ "settings" , sub_route..] => RouterTarget :: Settings ( parse ( & sub_route. join ( "/" ) ) ?) ,
96+ [ "bar" , name, id] => {
97+ RouterTarget :: Bar ( name. to_string ( ) , parse ( id) ?)
98+ }
99+ [ "settings" , sub_route] => {
100+ RouterTarget :: Settings ( parse ( & sub_route. join ( "/" ) ) ?)
101+ }
87102 _ => Err ( ( ) ) ?,
88103 } )
89104 }
@@ -181,7 +196,8 @@ impl Component for RootComponent {
181196 fn create ( _: Self :: Properties , mut link : ComponentLink < Self > ) -> Self {
182197 // Connect to the router agent using Yew's bridge method for workers
183198 // Send back the method we will be using to route the user
184- let mut router_agent = RouterAgent :: bridge ( link. send_back ( PageActions :: Route ) ) ;
199+ let mut router_agent =
200+ RouterAgent :: bridge ( link. send_back ( PageActions :: Route ) ) ;
185201 router_agent. send ( yew_router:: Request :: GetCurrentRoute ) ;
186202
187203 RootComponent {
0 commit comments