Skip to content

Commit

Permalink
Implement From<Style> for container::StyleFn
Browse files Browse the repository at this point in the history
Co-authored-by: wiiznokes <[email protected]>
  • Loading branch information
hecrj and wiiznokes committed Sep 2, 2024
1 parent feff4d1 commit 9d7aa11
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions widget/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

Expand Down

0 comments on commit 9d7aa11

Please sign in to comment.