Reintroduce Box for style_sheet in TextInput

This commit is contained in:
Héctor Ramón Jiménez 2021-10-31 17:45:57 +07:00
parent 0c76e0307f
commit 0d3c9ef7bd
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
4 changed files with 25 additions and 10 deletions

View file

@ -66,7 +66,7 @@ pub struct TextInput<'a, Message, Renderer: text::Renderer> {
size: Option<u16>,
on_change: Box<dyn Fn(String) -> Message>,
on_submit: Option<Message>,
style_sheet: &'a dyn StyleSheet,
style_sheet: Box<dyn StyleSheet + 'a>,
}
impl<'a, Message, Renderer> TextInput<'a, Message, Renderer>
@ -152,7 +152,10 @@ where
}
/// Sets the style of the [`TextInput`].
pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self {
pub fn style(
mut self,
style_sheet: impl Into<Box<dyn StyleSheet + 'a>>,
) -> Self {
self.style_sheet = style_sheet.into();
self
}