chore: make clippy happier

This commit is contained in:
Jonathan Kelley committed 2022-01-24 19:52:12 -05:00
1 parent 732ec018c3
commit 26ada2c7c1
14 files changed
+55 -41

No files matched your search

+13 -15
View File
@@ -19,7 +19,7 @@ pub struct TodoItem {
}
pub fn app(cx: Scope<()>) -> Element {
let todos = use_state(&cx, || im_rc::HashMap::<u32, TodoItem>::default());
let todos = use_state(&cx, im_rc::HashMap::<u32, TodoItem>::default);
let filter = use_state(&cx, || FilterState::All);
let draft = use_state(&cx, || "".to_string());
let mut todo_id = use_state(&cx, || 0);
@@ -56,19 +56,17 @@ pub fn app(cx: Scope<()>) -> Element {
autofocus: "true",
oninput: move |evt| draft.set(evt.value.clone()),
onkeydown: move |evt| {
if evt.key == "Enter" {
if !draft.is_empty() {
todos.modify().insert(
*todo_id,
TodoItem {
id: *todo_id,
checked: false,
contents: draft.get().clone(),
},
);
todo_id += 1;
draft.set("".to_string());
}
if evt.key == "Enter" && !draft.is_empty() {
todos.modify().insert(
*todo_id,
TodoItem {
id: *todo_id,
checked: false,
contents: draft.get().clone(),
},
);
todo_id += 1;
draft.set("".to_string());
}
}
}
@@ -90,7 +88,7 @@ pub fn app(cx: Scope<()>) -> Element {
(show_clear_completed).then(|| rsx!(
button {
class: "clear-completed",
onclick: move |_| todos.modify().retain(|_, todo| todo.checked == false),
onclick: move |_| todos.modify().retain(|_, todo| !todo.checked),
"Clear completed"
}
))