Implement From<Style> for container::StyleFn

Co-authored-by: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
This commit is contained in:
Héctor Ramón Jiménez 2024-09-02 11:59:45 +02:00
parent feff4d1cba
commit 9d7aa11623
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

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