diff --git a/examples/crm.rs b/examples/crm.rs index e45cdfe6a..abdb72c4b 100644 --- a/examples/crm.rs +++ b/examples/crm.rs @@ -20,7 +20,7 @@ pub struct Client { type ClientContext = Arc>>; fn App(cx: Scope) -> Element { - use_router(cx, &|| RouterConfiguration::default(), &|| { + use_router(cx, &RouterConfiguration::default, &|| { Segment::content(comp(ClientList)) .fixed( "new", @@ -32,7 +32,7 @@ fn App(cx: Scope) -> Element { ) }); - use_context_provider::(&cx, Default::default); + use_context_provider::(cx, Default::default); render! { link { @@ -86,11 +86,11 @@ fn ClientList(cx: Scope) -> Element { struct ClientAddName; fn ClientAdd(cx: Scope) -> Element { let clients = use_context::(cx).unwrap(); - let first_name = use_state(&cx, String::new); - let last_name = use_state(&cx, String::new); - let description = use_state(&cx, String::new); + let first_name = use_state(cx, String::new); + let last_name = use_state(cx, String::new); + let description = use_state(cx, String::new); - let navigator = use_navigate(&cx).unwrap(); + let navigator = use_navigate(cx).unwrap(); cx.render(rsx! { h2 { "Add new Client" } @@ -178,7 +178,7 @@ fn ClientAdd(cx: Scope) -> Element { struct SettingsName; fn Settings(cx: Scope) -> Element { - let clients = use_context::(&cx).unwrap(); + let clients = use_context::(cx).unwrap(); cx.render(rsx! { h2 { "Settings" } diff --git a/examples/flat_router.rs b/examples/flat_router.rs index a0d1e3b7e..ab3f365dd 100644 --- a/examples/flat_router.rs +++ b/examples/flat_router.rs @@ -17,7 +17,7 @@ fn main() { } fn app(cx: Scope) -> Element { - use_router(cx, &|| RouterConfiguration::default(), &|| { + use_router(cx, &RouterConfiguration::default, &|| { Segment::content(comp(Home)) .fixed("games", comp(Games)) .fixed("play", comp(Play)) diff --git a/examples/link.rs b/examples/link.rs index b25ee11c3..b6dd43412 100644 --- a/examples/link.rs +++ b/examples/link.rs @@ -8,7 +8,7 @@ fn main() { } fn app(cx: Scope) -> Element { - use_router(cx, &|| RouterConfiguration::default(), &|| { + use_router(cx, &RouterConfiguration::default, &|| { Segment::content(comp(Home)).fixed("settings", comp(Settings)) }); diff --git a/examples/router.rs b/examples/router.rs index 46bce97d7..a71ca144f 100644 --- a/examples/router.rs +++ b/examples/router.rs @@ -8,7 +8,7 @@ fn main() { } fn app(cx: Scope) -> Element { - use_router(cx, &|| RouterConfiguration::default(), &|| { + use_router(cx, &RouterConfiguration::default, &|| { Segment::content(comp(Home)) .fixed( "users", @@ -79,7 +79,7 @@ fn User(cx: Scope) -> Element { let user = state.parameter::().unwrap(); - let query = state.query.as_ref().map(|q| q.clone()).unwrap_or_default(); + let query = state.query.as_ref().cloned().unwrap_or_default(); let bold = query.contains("bold") && !query.contains("bold=false"); cx.render(rsx! { diff --git a/examples/simple_desktop.rs b/examples/simple_desktop.rs index 35d101d83..aa6a505b6 100644 --- a/examples/simple_desktop.rs +++ b/examples/simple_desktop.rs @@ -14,7 +14,7 @@ fn main() { } fn app(cx: Scope) -> Element { - use_router(cx, &|| RouterConfiguration::default(), &|| { + use_router(cx, &RouterConfiguration::default, &|| { Segment::content(comp(Home)) .fixed( "blog", diff --git a/packages/router-core/src/service.rs b/packages/router-core/src/service.rs index 0860a50ca..8ef5ef49f 100644 --- a/packages/router-core/src/service.rs +++ b/packages/router-core/src/service.rs @@ -590,8 +590,8 @@ mod tests { assert!(state.parameters.is_empty()); assert_eq!(state.path, String::from("/fixed")); assert_eq!(state.query, Some(String::from("test=value"))); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); assert_eq!(s.names, state.name_map); } @@ -599,7 +599,7 @@ mod tests { fn update_routing_root_index() { let (mut s, _, _) = RouterService::<_, u8>::new( test_segment(), - Box::new(MemoryHistory::default()), + Box::::default(), Arc::new(|_| {}), None, ContentAtom("external target"), @@ -619,8 +619,8 @@ mod tests { assert_eq!(state.path, String::from("/")); assert!(state.query.is_none()); assert!(state.prefix.is_none()); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); } #[test] @@ -645,8 +645,8 @@ mod tests { }); assert!(state.parameters.is_empty()); assert_eq!(state.path, String::from("/fixed")); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); } #[test] @@ -699,7 +699,7 @@ mod tests { let (mut s, _, _) = RouterService::<_, u8>::new( Segment::empty(), - Box::new(MemoryHistory::default()), + Box::::default(), Arc::new(move |id| { ids2.lock().unwrap().push(id); }), @@ -727,7 +727,7 @@ mod tests { fn push_internal() { let (mut s, _, _) = RouterService::<_, u8>::new( test_segment(), - Box::new(MemoryHistory::default()), + Box::::default(), Arc::new(|_| {}), None, ContentAtom("external target"), @@ -746,15 +746,15 @@ mod tests { }); assert!(state.parameters.is_empty()); assert_eq!(state.path, String::from("/fixed")); - assert_eq!(state.can_go_back, true); - assert_eq!(state.can_go_forward, false); + assert!(state.can_go_back); + assert!(!state.can_go_forward); } #[test] fn push_named() { let (mut s, _, _) = RouterService::<_, u8>::new( test_segment(), - Box::new(MemoryHistory::default()), + Box::::default(), Arc::new(|_| {}), None, ContentAtom("external target"), @@ -773,8 +773,8 @@ mod tests { }); assert!(state.parameters.is_empty()); assert_eq!(state.path, String::from("/fixed")); - assert_eq!(state.can_go_back, true); - assert_eq!(state.can_go_forward, false); + assert!(state.can_go_back); + assert!(!state.can_go_forward); } #[test] @@ -811,15 +811,15 @@ mod tests { r }); assert_eq!(state.path, String::from("/fixed")); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); } #[test] fn replace_named() { let (mut s, _, _) = RouterService::<_, u8>::new( test_segment(), - Box::new(MemoryHistory::default()), + Box::::default(), Arc::new(|_| {}), None, ContentAtom("external target"), @@ -838,15 +838,15 @@ mod tests { }); assert!(state.parameters.is_empty()); assert_eq!(state.path, String::from("/fixed")); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); } #[test] fn replace_internal() { let (mut s, _, _) = RouterService::<_, u8>::new( test_segment(), - Box::new(MemoryHistory::default()), + Box::::default(), Arc::new(|_| {}), None, ContentAtom("external target"), @@ -865,8 +865,8 @@ mod tests { }); assert!(state.parameters.is_empty()); assert_eq!(state.path, String::from("/fixed")); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); } #[test] @@ -903,15 +903,15 @@ mod tests { r }); assert_eq!(state.path, String::from("/fixed")); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); } #[test] fn subscribe() { let (mut s, _, _) = RouterService::<_, u8>::new( Segment::empty(), - Box::new(MemoryHistory::default()), + Box::::default(), Arc::new(|_| {}), None, ContentAtom("external target"), @@ -982,8 +982,8 @@ mod tests { r }); assert_eq!(state.path, String::from("/%F0%9F%A5%B3")); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); } #[test] @@ -1006,8 +1006,8 @@ mod tests { assert!(state.names.is_empty()); assert!(state.parameters.is_empty()); assert_eq!(state.path, String::from("/%F0%9F%8E%BA")); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); } #[test] @@ -1078,7 +1078,7 @@ mod tests { assert_eq!(state.path, String::from("/")); assert!(state.query.is_none()); assert_eq!(state.prefix, Some(String::from("/prefix"))); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, false); + assert!(!state.can_go_back); + assert!(!state.can_go_forward); } } diff --git a/packages/router-core/src/utils/route.rs b/packages/router-core/src/utils/route.rs index 130ac8336..30ab504d8 100644 --- a/packages/router-core/src/utils/route.rs +++ b/packages/router-core/src/utils/route.rs @@ -252,8 +252,8 @@ mod tests { assert!(state.names.is_empty()); assert!(state.parameters.is_empty()); assert_eq!(state.path, String::from("/")); - assert_eq!(state.can_go_back, false); - assert_eq!(state.can_go_forward, true); + assert!(!state.can_go_back); + assert!(state.can_go_forward); } #[test] diff --git a/packages/router/examples/simple.rs b/packages/router/examples/simple.rs index d7e572271..8357933dd 100644 --- a/packages/router/examples/simple.rs +++ b/packages/router/examples/simple.rs @@ -12,7 +12,7 @@ fn main() { fn App(cx: Scope) -> Element { use_router( - &cx, + cx, &|| { #[cfg(not(feature = "web"))] let history = MemoryHistory::default(); diff --git a/packages/router/tests/via_ssr/link.rs b/packages/router/tests/via_ssr/link.rs index 49eb5c327..afa4acf8e 100644 --- a/packages/router/tests/via_ssr/link.rs +++ b/packages/router/tests/via_ssr/link.rs @@ -14,7 +14,7 @@ fn prepare(link: Component) -> String { } impl PartialEq for AppProps { - fn eq(&self, other: &Self) -> bool { + fn eq(&self, _other: &Self) -> bool { false } }