Ver Fonte

actually make clippy happy

Adrian Wannenmacher há 2 anos atrás
pai
commit
90c7e22f8b

+ 7 - 7
examples/crm.rs

@@ -20,7 +20,7 @@ pub struct Client {
 type ClientContext = Arc<Mutex<Vec<Client>>>;
 
 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::<ClientContext>(&cx, Default::default);
+    use_context_provider::<ClientContext>(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::<ClientContext>(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::<ClientContext>(&cx).unwrap();
+    let clients = use_context::<ClientContext>(cx).unwrap();
 
     cx.render(rsx! {
         h2 { "Settings" }

+ 1 - 1
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))

+ 1 - 1
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))
     });
 

+ 2 - 2
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::<UserId>().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! {

+ 1 - 1
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",

+ 31 - 31
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::<MemoryHistory>::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::<MemoryHistory>::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::<MemoryHistory>::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::<MemoryHistory>::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::<MemoryHistory>::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::<MemoryHistory>::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::<MemoryHistory>::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);
     }
 }

+ 2 - 2
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]

+ 1 - 1
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();

+ 1 - 1
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
         }
     }