From 67277fbf93f4c180eff67bdc4c9dcf84a54d3425 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 9 Jan 2024 06:46:49 +0100 Subject: Make `column` and `row` take an `IntoIterator` --- widget/src/column.rs | 4 ++-- widget/src/helpers.rs | 8 ++++---- widget/src/row.rs | 6 ++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/widget/src/column.rs b/widget/src/column.rs index 9867d97e..d6eea84b 100644 --- a/widget/src/column.rs +++ b/widget/src/column.rs @@ -41,9 +41,9 @@ where /// Creates a [`Column`] with the given elements. pub fn with_children( - children: impl Iterator>, + children: impl IntoIterator>, ) -> Self { - children.fold(Self::new(), |column, element| column.push(element)) + children.into_iter().fold(Self::new(), Self::push) } /// Sets the vertical spacing _between_ elements. diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index 75528a0c..4b988ae3 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -34,7 +34,7 @@ macro_rules! column { $crate::Column::new() ); ($($x:expr),+ $(,)?) => ( - $crate::Column::with_children([$($crate::core::Element::from($x)),+].into_iter()) + $crate::Column::with_children([$($crate::core::Element::from($x)),+]) ); } @@ -47,7 +47,7 @@ macro_rules! row { $crate::Row::new() ); ($($x:expr),+ $(,)?) => ( - $crate::Row::with_children([$($crate::core::Element::from($x)),+].into_iter()) + $crate::Row::with_children([$($crate::core::Element::from($x)),+]) ); } @@ -66,7 +66,7 @@ where /// Creates a new [`Column`] with the given children. pub fn column<'a, Message, Renderer>( - children: impl Iterator>, + children: impl IntoIterator>, ) -> Column<'a, Message, Renderer> where Renderer: core::Renderer, @@ -89,7 +89,7 @@ where /// /// [`Row`]: crate::Row pub fn row<'a, Message, Renderer>( - children: impl Iterator>, + children: impl IntoIterator>, ) -> Row<'a, Message, Renderer> where Renderer: core::Renderer, diff --git a/widget/src/row.rs b/widget/src/row.rs index bcbe9267..90fd2926 100644 --- a/widget/src/row.rs +++ b/widget/src/row.rs @@ -39,11 +39,9 @@ where /// Creates a [`Row`] with the given elements. pub fn with_children( - children: impl Iterator>, + children: impl IntoIterator>, ) -> Self { - children - .into_iter() - .fold(Self::new(), |column, element| column.push(element)) + children.into_iter().fold(Self::new(), Self::push) } /// Sets the horizontal spacing _between_ elements. -- cgit