diff --git a/native/src/widget/column.rs b/native/src/widget/column.rs index 104790d429..a7a6f242d5 100644 --- a/native/src/widget/column.rs +++ b/native/src/widget/column.rs @@ -30,6 +30,15 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { /// /// [`Column`]: struct.Column.html pub fn new() -> Self { + Self::with_children(Vec::new()) + } + + /// Creates a [`Column`] with the given elements. + /// + /// [`Column`]: struct.Column.html + pub fn with_children( + children: Vec>, + ) -> Self { Column { spacing: 0, padding: 0, @@ -38,7 +47,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { max_width: u32::MAX, max_height: u32::MAX, align_items: Align::Start, - children: Vec::new(), + children, } } diff --git a/native/src/widget/row.rs b/native/src/widget/row.rs index 775b953eec..c8812ea262 100644 --- a/native/src/widget/row.rs +++ b/native/src/widget/row.rs @@ -30,6 +30,15 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { /// /// [`Row`]: struct.Row.html pub fn new() -> Self { + Self::with_children(Vec::new()) + } + + /// Creates a [`Row`] with the given elements. + /// + /// [`Row`]: struct.Row.html + pub fn with_children( + children: Vec>, + ) -> Self { Row { spacing: 0, padding: 0, @@ -38,7 +47,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { max_width: u32::MAX, max_height: u32::MAX, align_items: Align::Start, - children: Vec::new(), + children, } } diff --git a/web/src/widget/column.rs b/web/src/widget/column.rs index 6454ffba71..25b88b0e5b 100644 --- a/web/src/widget/column.rs +++ b/web/src/widget/column.rs @@ -25,6 +25,13 @@ impl<'a, Message> Column<'a, Message> { /// /// [`Column`]: struct.Column.html pub fn new() -> Self { + Self::with_children(Vec::new()) + } + + /// Creates a [`Column`] with the given elements. + /// + /// [`Column`]: struct.Column.html + pub fn with_children(children: Vec>) -> Self { Column { spacing: 0, padding: 0, @@ -33,7 +40,7 @@ impl<'a, Message> Column<'a, Message> { max_width: u32::MAX, max_height: u32::MAX, align_items: Align::Start, - children: Vec::new(), + children, } } diff --git a/web/src/widget/row.rs b/web/src/widget/row.rs index 02035113f9..cfa10fdf82 100644 --- a/web/src/widget/row.rs +++ b/web/src/widget/row.rs @@ -25,6 +25,13 @@ impl<'a, Message> Row<'a, Message> { /// /// [`Row`]: struct.Row.html pub fn new() -> Self { + Self::with_children(Vec::new()) + } + + /// Creates a [`Row`] with the given elements. + /// + /// [`Row`]: struct.Row.html + pub fn with_children(children: Vec>) -> Self { Row { spacing: 0, padding: 0, @@ -33,7 +40,7 @@ impl<'a, Message> Row<'a, Message> { max_width: u32::MAX, max_height: u32::MAX, align_items: Align::Start, - children: Vec::new(), + children, } }