Reintroduce Box for style_sheet in Scrollable

This commit is contained in:
Héctor Ramón Jiménez 2021-10-31 17:39:24 +07:00
parent 48490c3d87
commit eed19dcf81
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
6 changed files with 29 additions and 17 deletions

View file

@ -14,7 +14,7 @@ pub struct Scrollable<'a, Message> {
max_height: u32,
content: Column<'a, Message>,
#[allow(dead_code)]
style_sheet: &'a dyn StyleSheet,
style_sheet: Box<dyn StyleSheet + 'a>,
}
impl<'a, Message> Scrollable<'a, Message> {
@ -78,11 +78,11 @@ impl<'a, Message> Scrollable<'a, Message> {
}
/// Sets the style of the [`Scrollable`] .
pub fn style<'b>(mut self, style_sheet: &'b dyn StyleSheet) -> Self
where
'b: 'a,
{
self.style_sheet = style_sheet;
pub fn style(
mut self,
style_sheet: impl Into<Box<dyn StyleSheet + 'a>>,
) -> Self {
self.style_sheet = style_sheet.into();
self
}