From 450aa8bba2eed9afb269d5a074f7ce2b8612b023 Mon Sep 17 00:00:00 2001 From: Jared Moulton Date: Fri, 1 Nov 2024 14:12:25 -0600 Subject: [PATCH] remove view tuple extension (#651) --- src/view_tuple.rs | 23 ++++++++++++++++++++++- src/views/stack.rs | 22 ---------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/view_tuple.rs b/src/view_tuple.rs index 77703db8..825f4689 100644 --- a/src/view_tuple.rs +++ b/src/view_tuple.rs @@ -1,7 +1,25 @@ -use crate::view::{IntoView, View}; +use taffy::FlexDirection; + +use crate::{ + view::{IntoView, View}, + views::{create_stack, Stack}, +}; pub trait ViewTuple { fn into_views(self) -> Vec>; + fn stack(self, direction: FlexDirection) -> Stack; + fn v_stack(self) -> Stack + where + Self: Sized, + { + ViewTuple::stack(self, FlexDirection::Column) + } + fn h_stack(self) -> Stack + where + Self: Sized, + { + ViewTuple::stack(self, FlexDirection::Row) + } } // Macro to implement ViewTuple for tuples of Views and Vec> @@ -15,6 +33,9 @@ macro_rules! impl_view_tuple { $($t.into_any(),)+ ] } + fn stack(self, direction: FlexDirection) -> Stack { + create_stack(self.into_views(), Some(direction)) + } } impl<$($t: IntoView + 'static),+> IntoView for ($($t,)+) { diff --git a/src/views/stack.rs b/src/views/stack.rs index 134b4b13..644544c2 100644 --- a/src/views/stack.rs +++ b/src/views/stack.rs @@ -155,25 +155,3 @@ impl + 'static> StackExt for T from_iter(self, Some(direction)) } } -// Necessary to have a separate Ext trait because IntoIterator could be implemented on tuples of specific view types -pub trait TupleStackExt { - fn stack(self, direction: FlexDirection) -> Stack; - fn v_stack(self) -> Stack - where - Self: Sized, - { - TupleStackExt::stack(self, FlexDirection::Column) - } - fn h_stack(self) -> Stack - where - Self: Sized, - { - TupleStackExt::stack(self, FlexDirection::Row) - } -} - -impl TupleStackExt for T { - fn stack(self, direction: FlexDirection) -> Stack { - create_stack(self.into_views(), Some(direction)) - } -}