diff options
author | 2025-02-11 20:25:48 +0100 | |
---|---|---|
committer | 2025-02-11 20:25:48 +0100 | |
commit | 7d99e4d07e0fa6b60b802b18312b825c9c09fe29 (patch) | |
tree | 515aa7306a64a46148f7e1e1303448253fb7c4b4 | |
parent | eab723866e1dc94ebd6d7c5c0c3ef191c80bcf59 (diff) | |
download | iced-7d99e4d07e0fa6b60b802b18312b825c9c09fe29.tar.gz iced-7d99e4d07e0fa6b60b802b18312b825c9c09fe29.tar.bz2 iced-7d99e4d07e0fa6b60b802b18312b825c9c09fe29.zip |
Use `Function` trait in `Element::map` example
-rw-r--r-- | core/src/element.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/src/element.rs b/core/src/element.rs index ede9e16c..b7d51aeb 100644 --- a/core/src/element.rs +++ b/core/src/element.rs @@ -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() |