From e29e12675d9bbfcb042b52b0961d29d0acc1567b Mon Sep 17 00:00:00 2001 From: Luke Chu <37006668+lukechu10@users.noreply.github.com> Date: Tue, 2 Apr 2024 22:33:19 -0700 Subject: [PATCH] Fix warnings --- examples/attributes-passthrough/src/main.rs | 38 +++++++++++--------- examples/higher-order-components/src/main.rs | 6 ++-- packages/sycamore-web/src/bind.rs | 4 +-- packages/sycamore-web/src/dom.rs | 3 +- packages/sycamore-web/src/elements.rs | 6 +--- packages/sycamore-web/src/iter.rs | 1 - packages/sycamore/src/web.rs | 1 + 7 files changed, 27 insertions(+), 32 deletions(-) diff --git a/examples/attributes-passthrough/src/main.rs b/examples/attributes-passthrough/src/main.rs index ee9e6c19..39971e05 100644 --- a/examples/attributes-passthrough/src/main.rs +++ b/examples/attributes-passthrough/src/main.rs @@ -1,40 +1,44 @@ use sycamore::prelude::*; #[derive(Props)] -pub struct AccessibleInputProps { +pub struct AccessibleInputProps { label_id: &'static str, - attributes: Attributes, - children: Children, + // attributes: Attributes, + children: Children, } #[component] -fn AccessibleSearchBox(props: AccessibleInputProps) -> View { - props - .attributes - .exclude_keys(&["aria-role", "aria-labelledby"]); - let children = props.children.call(); - - view! { - input(aria-role="searchbox", aria-labelledby=props.label_id, ..props.attributes) { - (children) - } - } +fn AccessibleSearchBox(props: AccessibleInputProps) -> View { + let _ = props.label_id; + let _ = props.children; + // props + // .attributes + // .exclude_keys(&["aria-role", "aria-labelledby"]); + // let children = props.children.call(); + // + // view! { + // input(aria-role="searchbox", aria-labelledby=props.label_id, ..props.attributes) { + // (children) + // } + // } + todo!("attributes passthrough") } #[component] -fn App() -> View { +fn App() -> View { view! { div { p { "Passthrough attributes demo" } div { label(id="searchbox1_label") { "Search Box 1" } - AccessibleSearchBox(label_id="searchbox1_label", attr:style="background-color:red;") {} + // AccessibleSearchBox(label_id="searchbox1_label", attr:style="background-color:red;") {} + AccessibleSearchBox(label_id="searchbox1_label") {} } div { label(id="searchbox2_label") { "Search Box 2" } - AccessibleSearchBox(label_id="searchbox2_label", attr:style="background-color:yellow;") { } + // AccessibleSearchBox(label_id="searchbox2_label", attr:style="background-color:yellow;") { } } } } diff --git a/examples/higher-order-components/src/main.rs b/examples/higher-order-components/src/main.rs index 029bac9f..4a5deb3c 100644 --- a/examples/higher-order-components/src/main.rs +++ b/examples/higher-order-components/src/main.rs @@ -8,15 +8,13 @@ pub struct MyComponentProps { } #[component] -fn MyComponent(props: MyComponentProps) -> View { +fn MyComponent(props: MyComponentProps) -> View { view! { (props.value) } } -fn higher_order_component( - Comp: &dyn Fn(MyComponentProps) -> View, -) -> impl Fn() -> View + '_ { +fn higher_order_component(Comp: &dyn Fn(MyComponentProps) -> View) -> impl Fn() -> View + '_ { move || { view! { div { diff --git a/packages/sycamore-web/src/bind.rs b/packages/sycamore-web/src/bind.rs index 93533983..5af52aa0 100644 --- a/packages/sycamore-web/src/bind.rs +++ b/packages/sycamore-web/src/bind.rs @@ -1,8 +1,6 @@ //! Definition for bind-able attributes/properties. -use wasm_bindgen::JsValue; - -use self::events::EventDescriptor; +use crate::events::EventDescriptor; use crate::*; /// Description for a bind-able attribute/property. diff --git a/packages/sycamore-web/src/dom.rs b/packages/sycamore-web/src/dom.rs index 42749da4..23cbeb90 100644 --- a/packages/sycamore-web/src/dom.rs +++ b/packages/sycamore-web/src/dom.rs @@ -1,5 +1,4 @@ -use wasm_bindgen::closure::Closure; -use wasm_bindgen::{intern, JsValue}; +use wasm_bindgen::intern; use crate::*; diff --git a/packages/sycamore-web/src/elements.rs b/packages/sycamore-web/src/elements.rs index df918daa..6c74fb7a 100644 --- a/packages/sycamore-web/src/elements.rs +++ b/packages/sycamore-web/src/elements.rs @@ -1,10 +1,6 @@ #![allow(non_snake_case)] -use std::cell::Cell; - -use wasm_bindgen::JsValue; - -use super::*; +use crate::*; /// Create an HTML element with `tag`. pub(crate) fn element(tag: &'static str) -> HtmlElement { diff --git a/packages/sycamore-web/src/iter.rs b/packages/sycamore-web/src/iter.rs index b978170f..aed79516 100644 --- a/packages/sycamore-web/src/iter.rs +++ b/packages/sycamore-web/src/iter.rs @@ -5,7 +5,6 @@ #![allow(non_snake_case)] -use std::cell::Cell; use std::collections::HashMap; use std::hash::Hash; use std::ops::Deref; diff --git a/packages/sycamore/src/web.rs b/packages/sycamore/src/web.rs index 0f556121..e80e8127 100644 --- a/packages/sycamore/src/web.rs +++ b/packages/sycamore/src/web.rs @@ -13,6 +13,7 @@ use crate::prelude::*; /// _This API requires the following crate features to be activated: `suspense`, `ssr`_ #[cfg(all(feature = "ssr", feature = "suspense"))] pub async fn render_to_string_await_suspense(view: impl FnOnce() -> View + 'static) -> String { + let _ = view; // use std::cell::RefCell; // use std::rc::Rc; //