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

@ -39,7 +39,7 @@ pub struct TextInput<'a, Message> {
size: Option<u16>,
on_change: Rc<Box<dyn Fn(String) -> Message>>,
on_submit: Option<Message>,
style_sheet: &'a dyn StyleSheet,
style_sheet: Box<dyn StyleSheet + 'a>,
}
impl<'a, Message> TextInput<'a, Message> {
@ -112,8 +112,11 @@ impl<'a, Message> TextInput<'a, Message> {
}
/// Sets the style of the [`TextInput`].
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
}
}