Use Function trait in Element::map example

This commit is contained in:
Héctor Ramón Jiménez 2025-02-11 20:25:48 +01:00
parent eab723866e
commit 7d99e4d07e
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -93,6 +93,7 @@ impl<'a, Message, Theme, Renderer> Element<'a, Message, Theme, Renderer> {
///
/// ```no_run
/// # mod iced {
/// # pub use iced_core::Function;
/// # pub type Element<'a, Message> = iced_core::Element<'a, Message, iced_core::Theme, ()>;
/// #
/// # pub mod widget {
@ -119,7 +120,7 @@ impl<'a, Message, Theme, Renderer> Element<'a, Message, Theme, Renderer> {
/// use counter::Counter;
///
/// use iced::widget::row;
/// use iced::Element;
/// use iced::{Element, Function};
///
/// struct ManyCounters {
/// counters: Vec<Counter>,
@ -142,7 +143,7 @@ impl<'a, Message, Theme, Renderer> Element<'a, Message, Theme, Renderer> {
/// // Here we turn our `Element<counter::Message>` into
/// // an `Element<Message>` by combining the `index` and the
/// // message of the `element`.
/// counter.map(move |message| Message::Counter(index, message))
/// counter.map(Message::Counter.with(index))
/// }),
/// )
/// .into()