Reintroduce Box for style_sheet in Radio

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

View file

@ -53,7 +53,7 @@ pub struct Radio<'a, Message, Renderer: text::Renderer> {
text_size: Option<u16>,
text_color: Option<Color>,
font: Renderer::Font,
style_sheet: &'a dyn StyleSheet,
style_sheet: Box<dyn StyleSheet + 'a>,
}
impl<'a, Message, Renderer: text::Renderer> Radio<'a, Message, Renderer>
@ -135,8 +135,11 @@ where
}
/// Sets the style of the [`Radio`] button.
pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self {
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
}
}