Reintroduce Box for style_sheet in Container

This commit is contained in:
Héctor Ramón Jiménez 2021-10-31 17:02:59 +07:00
parent fcc282bd76
commit 40a5de5811
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
12 changed files with 51 additions and 30 deletions

View file

@ -19,7 +19,7 @@ pub struct Container<'a, Message> {
max_height: u32,
horizontal_alignment: alignment::Horizontal,
vertical_alignment: alignment::Vertical,
style_sheet: &'a dyn StyleSheet,
style_sheet: Box<dyn StyleSheet + 'a>,
content: Element<'a, Message>,
}
@ -89,8 +89,8 @@ impl<'a, Message> Container<'a, Message> {
}
/// Sets the style of the [`Container`].
pub fn style(mut self, style: &'a dyn StyleSheet) -> Self {
self.style_sheet = style;
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet + 'a>>) -> Self {
self.style_sheet = style.into();
self
}
}