Skip to content

Commit b246077

Browse files
committed
lint: fmt + clippy on examples
1 parent 31edf6f commit b246077

3 files changed

Lines changed: 42 additions & 43 deletions

File tree

example/nav_portlet/src/app.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use leptos::prelude::*;
2-
use leptos_meta::{MetaTags, *};
2+
use leptos_meta::{provide_meta_context, Meta, MetaTags, Stylesheet, Title};
33
use leptos_router::{
44
components::{ParentRoute, Route, Router, Routes, A},
55
hooks::use_params,
66
nested_router::Outlet,
77
params::Params,
8-
path, MatchNestedRoutes, ParamSegment, SsrMode, StaticSegment,
8+
path, ParamSegment, SsrMode, StaticSegment,
99
};
1010

1111
use leptos_sync_ssr::component::SyncSsrSignal;
@@ -304,7 +304,7 @@ pub fn HomePage() -> impl IntoView {
304304
}
305305

306306
#[component]
307-
pub fn AuthorRoutes() -> impl MatchNestedRoutes + Clone {
307+
pub fn AuthorRoutes() -> impl leptos_router::MatchNestedRoutes + Clone {
308308
view! {
309309
<ParentRoute path=StaticSegment("author") view=AuthorContainer ssr=SsrMode::Async>
310310
<Route path=StaticSegment("/") view=AuthorListing/>
@@ -389,7 +389,7 @@ pub fn AuthorTop() -> impl IntoView {
389389
let nav_ctx = expect_context::<NavPortletCtx>();
390390
let info_ctx = expect_context::<InfoPortletCtx>();
391391

392-
#[cfg(not(feature="ssr"))]
392+
#[cfg(not(feature = "ssr"))]
393393
on_cleanup({
394394
let nav_ctx = nav_ctx.clone();
395395
let info_ctx = info_ctx.clone();
@@ -468,7 +468,7 @@ pub fn AuthorOverview() -> impl IntoView {
468468
}
469469

470470
#[component]
471-
pub fn ArticleRoutes() -> impl MatchNestedRoutes + Clone {
471+
pub fn ArticleRoutes() -> impl leptos_router::MatchNestedRoutes + Clone {
472472
view! {
473473
<ParentRoute path=StaticSegment("article") view=ArticleContainer ssr=SsrMode::Async>
474474
<Route path=StaticSegment("/") view=ArticleListing/>

example/nav_portlet_alt/src/app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use leptos::prelude::*;
2-
use leptos_meta::{MetaTags, *};
2+
use leptos_meta::{provide_meta_context, Meta, MetaTags, Stylesheet, Title};
33
use leptos_router::{
44
components::{ParentRoute, Route, Router, Routes, A},
55
hooks::use_params,
66
nested_router::Outlet,
77
params::Params,
8-
path, MatchNestedRoutes, ParamSegment, SsrMode, StaticSegment,
8+
path, ParamSegment, SsrMode, StaticSegment,
99
};
1010

1111
use leptos_sync_ssr::component::SyncSsr;
@@ -304,7 +304,7 @@ pub fn HomePage() -> impl IntoView {
304304
}
305305

306306
#[component]
307-
pub fn AuthorRoutes() -> impl MatchNestedRoutes + Clone {
307+
pub fn AuthorRoutes() -> impl leptos_router::MatchNestedRoutes + Clone {
308308
view! {
309309
<ParentRoute path=StaticSegment("author") view=AuthorContainer ssr=SsrMode::Async>
310310
<Route path=StaticSegment("/") view=AuthorListing/>
@@ -483,7 +483,7 @@ pub fn AuthorOverview() -> impl IntoView {
483483
}
484484

485485
#[component]
486-
pub fn ArticleRoutes() -> impl MatchNestedRoutes + Clone {
486+
pub fn ArticleRoutes() -> impl leptos_router::MatchNestedRoutes + Clone {
487487
view! {
488488
<ParentRoute path=StaticSegment("article") view=ArticleContainer ssr=SsrMode::Async>
489489
<Route path=StaticSegment("/") view=ArticleListing/>

example/simple/src/app.rs

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ pub fn HomePage() -> impl IntoView {
7979
}
8080

8181
#[component]
82-
pub fn UsingSignal(
83-
rs: ReadSignal<Option<OnceResource<String>>>,
84-
) -> impl IntoView {
82+
pub fn UsingSignal(rs: ReadSignal<Option<OnceResource<String>>>) -> impl IntoView {
8583
// Ready will have _no_ effect whatsoever if this component is not
8684
// enclosed by the `SyncSsr` component.
8785
// #[cfg(feature = "ssr")]
@@ -100,16 +98,19 @@ pub fn UsingSignal(
10098
// #[cfg(feature = "ssr")]
10199
ready.subscribe().wait().await;
102100
// leptos::logging::log!("subscription finished waiting");
103-
let value = if let Some(Some(res)) = rs.try_get() {
101+
// let value = if let Some(Some(res)) = rs.try_get() {
102+
if let Some(Some(res)) = rs.try_get() {
104103
// leptos::logging::log!("readsignal has OnceResource");
105-
let result = Some(res.await);
104+
// let result = Some(res.await);
106105
// leptos::logging::log!("finished awaiting for OnceResource");
107-
result
106+
// result
107+
Some(res.await)
108108
} else {
109109
None
110-
};
110+
}
111+
// };
111112
// leptos::logging::log!("value: {value:?}");
112-
value
113+
// value
113114
}
114115
},
115116
);
@@ -120,18 +121,22 @@ pub fn UsingSignal(
120121
<Suspense>{
121122
move || Suspend::new(async move {
122123
// leptos::logging::log!("Inside suspense");
123-
let result = if let Some(value) = value.await {
124-
// leptos::logging::log!("value.await got Some");
125-
Some(view! {
126-
<strong id="target">{value}</strong>
127-
}
128-
.into_any())
129-
} else {
130-
// leptos::logging::log!("value.await got None");
131-
None
132-
};
124+
// let result = if let Some(value) = value.await {
125+
// leptos::logging::log!("value.await got Some");
126+
// Some(view! {
127+
// <strong id="target">{value}</strong>
128+
// }
129+
// .into_any())
130+
// } else {
131+
// leptos::logging::log!("value.await got None");
132+
// None
133+
// };
133134
// leptos::logging::log!("Suspense rendered");
134-
result
135+
// result
136+
value.await.map(|value| view! {
137+
<strong id="target">{value}</strong>
138+
}
139+
.into_any())
135140
})
136141
}</Suspense>
137142
"."
@@ -140,29 +145,24 @@ pub fn UsingSignal(
140145
}
141146

142147
#[component]
143-
pub fn SettingSignal(
144-
ws: WriteSignal<Option<OnceResource<String>>>,
145-
) -> impl IntoView {
148+
pub fn SettingSignal(ws: WriteSignal<Option<OnceResource<String>>>) -> impl IntoView {
146149
on_cleanup(move || {
147150
// leptos::logging::log!("Running on_cleanup");
148151
ws.try_set(None);
149152
});
150153

151-
let server_call = Resource::new_blocking(
152-
|| (),
153-
|_| async move {
154-
server_call().await
155-
},
156-
);
154+
let server_call = Resource::new_blocking(|| (), |_| async move { server_call().await });
157155

158156
let static_value = "Hello World!";
159157
// while the resource can be set via the signal directly here, having
160158
// a hook that gets called when the view is initiated emulates a kind
161159
// of reactivity that would determine whether or not it is set.
162-
let hook = move || ws.set(Some(OnceResource::new(async move {
163-
let _ = server_call.await;
164-
static_value.to_string()
165-
})));
160+
let hook = move || {
161+
ws.set(Some(OnceResource::new(async move {
162+
let _ = server_call.await;
163+
static_value.to_string()
164+
})))
165+
};
166166
view! {
167167
{hook}
168168
// If the following block is inside a Suspense that awaits some
@@ -223,8 +223,7 @@ pub fn NonIssue() -> impl IntoView {
223223

224224
#[component]
225225
pub fn HydrationIssue(
226-
#[prop(default = "Below can result in hydration issue")]
227-
title: &'static str,
226+
#[prop(default = "Below can result in hydration issue")] title: &'static str,
228227
children: Children,
229228
) -> impl IntoView {
230229
let (rs, ws) = signal(None::<OnceResource<String>>);

0 commit comments

Comments
 (0)