Skip to content

Commit 5b1ef2e

Browse files
committed
fix some lints and use $crate consistently in macro_rules
1 parent a3debc9 commit 5b1ef2e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

packages/yew/src/lazy.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ use crate::suspense::Suspension;
1313
use crate::virtual_dom::VComp;
1414
use crate::{BaseComponent, Context};
1515

16+
type ScopeRef<C> = Shared<Option<Scope<C>>>;
17+
1618
#[derive(Debug)]
1719
struct CompVTableImpl<C: BaseComponent> {
1820
/// The way to create a component from properties and a way to reference it later.
1921
/// It is important that we return a structure that already captures the vtable to
2022
/// the component's functionality (Mountable), so that the linker doesn't see that
2123
/// the main module references C's BaseComponent impl.
22-
wrap_html: fn(Rc<C::Properties>, Shared<Option<Scope<C>>>) -> VComp,
24+
wrap_html: fn(Rc<C::Properties>, ScopeRef<C>) -> VComp,
2325
}
2426
/// Component vtable for a component.
2527
///
@@ -92,7 +94,7 @@ impl<C: BaseComponent> std::fmt::Debug for LazyState<C> {
9294
/// This component suspends as long as the underlying component is still being fetched,
9395
/// then behaves as the underlying component itself.
9496
pub struct Lazy<C: LazyComponent> {
95-
inner_scope: Shared<Option<Scope<C::Underlying>>>,
97+
inner_scope: ScopeRef<C::Underlying>,
9698
// messages sent to the component before the inner_scope is set are buffered
9799
message_buffer: RefCell<Vec<<C::Underlying as BaseComponent>::Message>>,
98100
state: Shared<LazyState<C::Underlying>>,
@@ -187,26 +189,26 @@ impl<C: LazyComponent> BaseComponent for Lazy<C> {
187189
macro_rules! __declare_lazy_component {
188190
($comp:ty as $lazy_name:ident in $module:ident) => {
189191
struct Proxy;
190-
impl ::yew::lazy::LazyComponent for Proxy {
192+
impl $crate::lazy::LazyComponent for Proxy {
191193
type Underlying = $comp;
192194

193-
async fn fetch() -> ::yew::lazy::LazyVTable<Self::Underlying> {
195+
async fn fetch() -> $crate::lazy::LazyVTable<Self::Underlying> {
194196
#[$crate::lazy::wasm_split::wasm_split($module, wasm_split_path = $crate::lazy::wasm_split)]
195-
fn split_fetch() -> ::yew::lazy::LazyVTable<$comp> {
196-
::yew::lazy::LazyVTable::<$comp>::vtable()
197+
fn split_fetch() -> $crate::lazy::LazyVTable<$comp> {
198+
$crate::lazy::LazyVTable::<$comp>::vtable()
197199
}
198200
struct F(
199201
::std::option::Option<
200202
::std::pin::Pin<
201203
::std::boxed::Box<
202-
dyn ::std::future::Future<Output = ::yew::lazy::LazyVTable<$comp>>
204+
dyn ::std::future::Future<Output = $crate::lazy::LazyVTable<$comp>>
203205
+ ::std::marker::Send,
204206
>,
205207
>,
206208
>,
207209
);
208210
impl Future for F {
209-
type Output = ::yew::lazy::LazyVTable<$comp>;
211+
type Output = $crate::lazy::LazyVTable<$comp>;
210212

211213
fn poll(
212214
mut self: ::std::pin::Pin<&mut Self>,
@@ -218,12 +220,12 @@ macro_rules! __declare_lazy_component {
218220
.poll(cx)
219221
}
220222
}
221-
static CACHE: ::yew::lazy::LazyCell<::yew::lazy::LazyVTable<$comp>, F> =
222-
::yew::lazy::LazyCell::new(F(None));
223+
static CACHE: $crate::lazy::LazyCell<$crate::lazy::LazyVTable<$comp>, F> =
224+
$crate::lazy::LazyCell::new(F(None));
223225
*::std::pin::Pin::static_ref(&CACHE).await.get_ref()
224226
}
225227
}
226-
type $lazy_name = ::yew::lazy::Lazy<Proxy>;
228+
type $lazy_name = $crate::lazy::Lazy<Proxy>;
227229
};
228230
}
229231
#[doc(hidden)]

0 commit comments

Comments
 (0)