summaryrefslogtreecommitdiffstats
path: root/widget/src/helpers.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-19 03:54:29 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-19 03:54:29 +0200
commit70dd0501af2084f410b4511d6ddc63296b643f00 (patch)
treebe8d8e7b612a0cd60993e42ebbc36fcf3feab7e6 /widget/src/helpers.rs
parente98a441b0fa0c1e2ddffe615a48f3fe23a4fedad (diff)
downloadiced-70dd0501af2084f410b4511d6ddc63296b643f00.tar.gz
iced-70dd0501af2084f410b4511d6ddc63296b643f00.tar.bz2
iced-70dd0501af2084f410b4511d6ddc63296b643f00.zip
Show `keyed_column` doc example in multiple places
Diffstat (limited to 'widget/src/helpers.rs')
-rw-r--r--widget/src/helpers.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs
index bae2e10e..11eed6ba 100644
--- a/widget/src/helpers.rs
+++ b/widget/src/helpers.rs
@@ -191,7 +191,27 @@ where
Column::with_children(children)
}
-/// Creates a new [`keyed::Column`] with the given children.
+/// Creates a new [`keyed::Column`] from an iterator of elements.
+///
+/// Keyed columns distribute content vertically while keeping continuity.
+///
+/// # Example
+/// ```no_run
+/// # mod iced { pub mod widget { pub use iced_widget::*; } }
+/// # pub type State = ();
+/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
+/// use iced::widget::{keyed_column, text};
+///
+/// enum Message {
+/// // ...
+/// }
+///
+/// fn view(state: &State) -> Element<'_, Message> {
+/// keyed_column((0..=100).map(|i| {
+/// (i, text!("Item {i}").into())
+/// })).into()
+/// }
+/// ```
pub fn keyed_column<'a, Key, Message, Theme, Renderer>(
children: impl IntoIterator<Item = (Key, Element<'a, Message, Theme, Renderer>)>,
) -> keyed::Column<'a, Key, Message, Theme, Renderer>