diff options
author | 2024-04-16 00:08:17 +0900 | |
---|---|---|
committer | 2024-04-16 00:08:17 +0900 | |
commit | 0ebe0629cef37aee5c48b9409fc36618a3a3e60d (patch) | |
tree | 909d9ecf28e7c491bae3afc81928c118517fa7a9 /widget/src/row.rs | |
parent | 13bd106fc585034a7aba17b9c17589113274aaf5 (diff) | |
parent | 105b8bd5ad6ade1f203a0d8b0b93bd06f61f621a (diff) | |
download | iced-0ebe0629cef37aee5c48b9409fc36618a3a3e60d.tar.gz iced-0ebe0629cef37aee5c48b9409fc36618a3a3e60d.tar.bz2 iced-0ebe0629cef37aee5c48b9409fc36618a3a3e60d.zip |
Merge branch 'iced-rs:master' into viewer_content_fit
Diffstat (limited to 'widget/src/row.rs')
-rw-r--r-- | widget/src/row.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/widget/src/row.rs b/widget/src/row.rs index 47feff9c..fa352171 100644 --- a/widget/src/row.rs +++ b/widget/src/row.rs @@ -31,11 +31,18 @@ where Self::from_vec(Vec::new()) } + /// Creates a [`Row`] with the given capacity. + pub fn with_capacity(capacity: usize) -> Self { + Self::from_vec(Vec::with_capacity(capacity)) + } + /// Creates a [`Row`] with the given elements. pub fn with_children( children: impl IntoIterator<Item = Element<'a, Message, Theme, Renderer>>, ) -> Self { - Self::new().extend(children) + let iterator = children.into_iter(); + + Self::with_capacity(iterator.size_hint().0).extend(iterator) } /// Creates a [`Row`] from an already allocated [`Vec`]. |