Show keyed_column doc example in multiple places

This commit is contained in:
Héctor Ramón Jiménez 2024-09-19 03:54:29 +02:00
parent e98a441b0f
commit 70dd0501af
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 68 additions and 8 deletions

View file

@ -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>