summaryrefslogtreecommitdiffstats
path: root/widget/src/container.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2024-09-02 11:59:45 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2024-09-02 12:00:55 +0200
commit9d7aa116238465cdc23ff7de868e7ff3b77db6a5 (patch)
tree592ccce9539f4c2a334e2fdfc4fa1417d9e05217 /widget/src/container.rs
parentfeff4d1cba1766a0e4901865f268cc90e7618c62 (diff)
downloadiced-9d7aa116238465cdc23ff7de868e7ff3b77db6a5.tar.gz
iced-9d7aa116238465cdc23ff7de868e7ff3b77db6a5.tar.bz2
iced-9d7aa116238465cdc23ff7de868e7ff3b77db6a5.zip
Implement `From<Style>` for `container::StyleFn`
Co-authored-by: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Diffstat (limited to '')
-rw-r--r--widget/src/container.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/widget/src/container.rs b/widget/src/container.rs
index 7eb50120..c3a66360 100644
--- a/widget/src/container.rs
+++ b/widget/src/container.rs
@@ -612,6 +612,12 @@ pub trait Catalog {
/// A styling function for a [`Container`].
pub type StyleFn<'a, Theme> = Box<dyn Fn(&Theme) -> Style + 'a>;
+impl<'a, Theme> From<Style> for StyleFn<'a, Theme> {
+ fn from(style: Style) -> Self {
+ Box::new(move |_theme| style)
+ }
+}
+
impl Catalog for Theme {
type Class<'a> = StyleFn<'a, Self>;