Skip to content

Commit 174487a

Browse files
committed
style(Frontend): 🎨 clippy
1 parent 6998c85 commit 174487a

File tree

7 files changed

+17
-27
lines changed

7 files changed

+17
-27
lines changed

frontend/src/components/editor.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ pub fn Editor(
7979

8080
let config = Object::new();
8181
Reflect::set(&config, &"theme".into(), &"vs-dark".into()).unwrap();
82-
Reflect::set(&config, &"automaticLayout".into(), &true.into())
83-
.unwrap();
82+
Reflect::set(&config, &"automaticLayout".into(), &true.into()).unwrap();
8483

8584
let init_monaco = Closure::once_into_js(move || {
8685
let editor = MONACO.editor().create_editor(
@@ -98,7 +97,7 @@ pub fn Editor(
9897

9998
create_effect(move |_| {
10099
editor_ref.with(|editor| {
101-
let Some(model) = editor.as_ref().map(|e| e.get_model()).flatten()
100+
let Some(model) = editor.as_ref().and_then(|e| e.get_model())
102101
else {
103102
return;
104103
};

frontend/src/components/paginate_navbar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn PaginateNavbarButton(
8080
class=move || {
8181
tw_join!(
8282
"size-8",
83-
disabled().then_some("bg-primary disabled").unwrap_or("bg-black-900")
83+
if disabled() { "bg-primary disabled" } else { "bg-black-900" }
8484
)
8585
}
8686
>

frontend/src/components/toast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn Toast(
105105
is_pending,
106106
..
107107
} = {
108-
let close = close.clone();
108+
let close = close;
109109
use_timeout_fn(move |_| close(), 4.0 * 1000.0)
110110
};
111111

frontend/src/utils/config.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,12 @@ impl Default for FrontendConfig {
9191
}
9292
}
9393

94-
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
94+
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize, Default)]
9595
pub struct BackendConfig {
9696
#[serde(default)]
9797
pub trust_xff: bool,
9898
}
9999

100-
impl Default for BackendConfig {
101-
fn default() -> Self {
102-
Self { trust_xff: false }
103-
}
104-
}
105-
106100
#[cfg(feature = "ssr")]
107101
pub async fn init_config() -> Result<()> {
108102
let config = load_config().await?;

frontend/src/utils/grpc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ where
5959
#[cfg(feature = "ssr")]
6060
fn with_xff(metadata: MetadataMap) -> MetadataMap {
6161
use actix_web::http::header;
62+
use leptos::*;
6263
use leptos_actix::ResponseOptions;
6364

6465
let mut header_map = metadata.into_headers();

frontend/src/utils/router.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
}
4444

4545
fn convert_to_type(s: &str) -> Option<Self::Output> {
46-
s.parse().ok().map(|n| T::try_from(n).ok()).flatten()
46+
s.parse().ok().and_then(|n| T::try_from(n).ok())
4747
}
4848

4949
fn convert_to_string(o: Self::Output) -> String {
@@ -57,7 +57,7 @@ where
5757

5858
impl<T: QueryType> Clone for ParamsMapKey<T> {
5959
fn clone(&self) -> Self {
60-
Self(self.0.clone())
60+
Self(self.0)
6161
}
6262
}
6363

@@ -75,7 +75,7 @@ impl<T: QueryType> Clone for InnerParamsMapKey<T> {
7575
Self {
7676
key: self.key,
7777
default: self.default.clone(),
78-
_maker: self._maker.clone(),
78+
_maker: self._maker,
7979
}
8080
}
8181
}
@@ -136,7 +136,7 @@ impl MemoParamsMapExtra for Memo<ParamsMap> {
136136
&self,
137137
f: impl Fn(&mut ParamsMap) + 'static,
138138
) -> Signal<String> {
139-
let map = self.clone();
139+
let map = *self;
140140
Signal::derive(move || {
141141
let mut map = map();
142142
f(&mut map);
@@ -159,15 +159,15 @@ impl MemoParamsMapExtra for Memo<ParamsMap> {
159159
&self,
160160
query: ParamsMapKey<T>,
161161
) -> Signal<Option<T::Output>> {
162-
let map = self.clone();
162+
let map = *self;
163163
Signal::derive(move || map().get_query(query))
164164
}
165165

166166
fn use_query_with_default<T: QueryType>(
167167
&self,
168168
query: ParamsMapKey<T>,
169169
) -> Signal<T::Output> {
170-
let map = self.clone();
170+
let map = *self;
171171
Signal::derive(move || map().get_query_with_default(query))
172172
}
173173
}
@@ -196,9 +196,7 @@ impl ParamsMapExtra for ParamsMap {
196196
where
197197
T: QueryType,
198198
{
199-
self.get(query.key())
200-
.map(|v| T::convert_to_type(v))
201-
.flatten()
199+
self.get(query.key()).and_then(|v| T::convert_to_type(v))
202200
}
203201

204202
fn get_query_with_default<T>(&self, query: ParamsMapKey<T>) -> T::Output
@@ -213,11 +211,9 @@ impl ParamsMapExtra for ParamsMap {
213211
where
214212
T: QueryType,
215213
{
216-
let value = value
217-
.map(move |v| {
218-
query.0.with_value(|query| v != query.default).then_some(v)
219-
})
220-
.flatten();
214+
let value = value.and_then(move |v| {
215+
query.0.with_value(|query| v != query.default).then_some(v)
216+
});
221217
match value {
222218
Some(value) => {
223219
self.insert(query.key().to_owned(), T::convert_to_string(value))

frontend/src/utils/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ pub fn use_token() -> Signal<Option<String>> {
3333

3434
pub fn use_role() -> Signal<Option<Role>> {
3535
let (user_info, _) = use_token_info();
36-
(move || user_info().as_ref().map(|s| s.role.clone())).into_signal()
36+
(move || user_info().as_ref().map(|s| s.role)).into_signal()
3737
}

0 commit comments

Comments
 (0)