use crate::{
BoxView, Child, NodeViewParts, View,
internal::{LiveView, MoveView, ScopeView},
};
pub trait NodeClassify {
type Parts: NodeViewParts;
type Unit: View;
fn classify(self) -> (Self::Parts, Self::Unit);
}
impl<T: NodeViewParts> NodeClassify for T {
type Parts = T;
type Unit = ();
#[inline]
fn classify(self) -> (Self::Parts, Self::Unit) {
(self, ())
}
}
macro_rules! classify_view {
($(#[$doc:meta])* impl<$($param:tt),*> for $ty:ty) => {
$(#[$doc])*
impl<$($param),*> NodeClassify for $ty
where
$ty: View,
{
type Parts = ();
type Unit = Self;
#[inline]
fn classify(self) -> (Self::Parts, Self::Unit) {
((), self)
}
}
};
}
classify_view! {
impl<'a> for Child<'a>
}
classify_view! {
impl<'a> for BoxView<'a>
}
classify_view! {
impl<Fut> for LiveView<Fut>
}
classify_view! {
impl<Fut> for MoveView<Fut>
}
classify_view! {
impl<V> for ScopeView<V>
}