diff --git a/packages/yew/src/virtual_dom/mod.rs b/packages/yew/src/virtual_dom/mod.rs index c90a175c9..940c46021 100644 --- a/packages/yew/src/virtual_dom/mod.rs +++ b/packages/yew/src/virtual_dom/mod.rs @@ -69,11 +69,20 @@ mod feat_ssr_hydration { } impl Collectable { + #[cfg(not(debug_assertions))] + #[inline(always)] + pub fn for_component() -> Self { + use std::marker::PhantomData; + // This suppresses the clippy lint about unused generic. + // We inline this function + // so the function body is copied to its caller and generics get optimised away. + let _comp_type: PhantomData = PhantomData; + Self::Component(PhantomData) + } + + #[cfg(debug_assertions)] pub fn for_component() -> Self { - #[cfg(debug_assertions)] let comp_name = std::any::type_name::(); - #[cfg(not(debug_assertions))] - let comp_name = std::marker::PhantomData; Self::Component(comp_name) }