Skip to content

Instantly share code, notes, and snippets.

@PoignardAzur
Last active May 9, 2024 12:39
Show Gist options
  • Save PoignardAzur/6f9be1178626ab16325c852940afb9db to your computer and use it in GitHub Desktop.
Save PoignardAzur/6f9be1178626ab16325c852940afb9db to your computer and use it in GitHub Desktop.
macro_rules! impl_into_view_for_tuples {
($($ty:ident),* $(,)?) => {
impl<$($ty),*> IntoView for ($($ty,)*)
where
$($ty: IntoView),*
{
#[inline]
fn into_view(self) -> View {
paste::paste! {
let ($([<$ty:lower>],)*) = self;
[
$([<$ty:lower>].into_view()),*
].into_view()
}
}
}
};
}
// ----
impl<...Ts: IntoView> IntoView for (...Ts) {
#[inline]
fn into_view(self) -> View {
let views = vec![];
for member, T in ...self {
views.push::<T>(member.into_view());
}
let views_tuple = for member: T in ...self {
member.into_view()
};
views.into_view()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment