Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
flosse committed Mar 5, 2023
1 parent 6b51f8d commit 0dbb7ba
Show file tree
Hide file tree
Showing 78 changed files with 522 additions and 416 deletions.
49 changes: 49 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "README.md"
keywords = ["wasm", "webassembly", "frontend", "framework", "web"]
categories = ["wasm", "web-programming"]
edition = "2021"
rust-version = "1.61.0"
rust-version = "1.67.1"

[workspace]
members = [
Expand Down Expand Up @@ -166,6 +166,6 @@ serde-wasm-bindgen = ["dep:serde", "dep:serde-wasm-bindgen"]
version_check = "0.9.4"

[dev-dependencies]
wasm-bindgen-test = "0.3.34"
serde_json = "1.0.93"
serde-wasm-bindgen = "0.4.5"
wasm-bindgen-test = "0.3.34"
2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ args = ["clippy", "--all-features", "--",
"--allow", "clippy::wildcard_imports", # for `use seed::{prelude::*, *};`
"--allow", "clippy::future_not_send", # JS/WASM is single threaded
"--allow", "clippy::used_underscore_binding", # some libraries break this rule
"--allow", "clippy::eval_order_dependence", # false positives
"--allow", "clippy::mixed_read_write_in_expression", # false positives
"--allow", "clippy::vec_init_then_push", # Vec::new() + push are used in macros in shortcuts.rs
]
dependencies = ["default::install-clippy"]
Expand Down
2 changes: 1 addition & 1 deletion examples/animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Car {

fn generate_color() -> CarColor {
let hue = thread_rng().gen_range(0..=360);
format!("hsl({}, 80%, 50%)", hue)
format!("hsl({hue}, 80%, 50%)")
}
}

Expand Down
2 changes: 2 additions & 0 deletions examples/auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
gloo-console = "0.2.3"
gloo-net = "0.2.6"
gloo-storage = "0.2.2"
seed = {path = "../../"}
serde = "1.0.152"
16 changes: 10 additions & 6 deletions examples/auth/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![allow(clippy::must_use_candidate)]

use gloo_console::log;
use gloo_net::http::{Method, Request};
use gloo_storage::{LocalStorage, Storage};
use seed::{prelude::*, *};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -77,8 +79,8 @@ fn send_request_to_top_secret(token: String, orders: &mut impl Orders<Msg>) {
orders.perform_cmd(async move {
Msg::TopSecretFetched(
async {
Request::get(&format!("{}/top_secret", API_URL))
.header("Authorization", &format!("Bearer {}", token))
Request::get(&format!("{API_URL}/top_secret"))
.header("Authorization", &format!("Bearer {token}"))
.send()
.await?
.text()
Expand Down Expand Up @@ -125,7 +127,7 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
Msg::EmailChanged(email) => model.email = email,
Msg::PasswordChanged(password) => model.password = password,
Msg::LoginClicked => {
let request = Request::new(&format!("{}/users/login", API_URL))
let request = Request::new(&format!("{API_URL}/users/login"))
.method(Method::POST)
.json(&LoginRequestBody {
email: &model.email,
Expand All @@ -136,16 +138,18 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
});
}
Msg::LoginFetched(Ok(logged_user)) => {
LocalStorage::insert(STORAGE_KEY, &logged_user).expect("save user");
LocalStorage::set(STORAGE_KEY, &logged_user).expect("save user");
model.user = Some(logged_user);
orders.notify(subs::UrlRequested::new(Urls::new(&model.base_url).home()));
}
Msg::TopSecretFetched(Ok(secret_message)) => {
model.secret_message = Some(secret_message);
}
Msg::LoginFetched(Err(error)) | Msg::TopSecretFetched(Err(error)) => log!(error),
Msg::LoginFetched(Err(error)) | Msg::TopSecretFetched(Err(error)) => {
log!(format!("{error}"));
}
Msg::LogoutClicked => {
LocalStorage::remove(STORAGE_KEY).expect("remove saved user");
LocalStorage::delete(STORAGE_KEY);
model.user = None;
model.secret_message = None;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/charts/src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn chart<Ms: Clone + 'static>(
C!["chart"],
style! { St::Display => "block" },
attrs! {
ViewBox => format!("0 0 {} {}", width, height),
ViewBox => format!("0 0 {width} {height}"),
},
g![
C!["x-axis"],
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_elements/src/checkbox_tristate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ impl fmt::Display for State {
Self::Indeterminate => "indeterminate",
Self::Checked => "checked",
};
write!(f, "{}", state)
write!(f, "{state}")
}
}
1 change: 1 addition & 0 deletions examples/drag_and_drop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
gloo-console = "0.2.3"
seed = {path = "../../"}
2 changes: 2 additions & 0 deletions examples/drag_and_drop/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use gloo_console::log;
use seed::{prelude::*, *};
use web_sys::{self, HtmlDivElement};

// ------ ------
// Init
// ------ ------
Expand Down

0 comments on commit 0dbb7ba

Please sign in to comment.