From 15f5b93a0d4b7b7fead8d1864c77e6df50b9a231 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Sat, 4 Apr 2020 13:21:45 +0700 Subject: Checkbox label is now `impl Into` --- native/src/widget/checkbox.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'native/src') diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 7f915456..ccf13848 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -50,14 +50,14 @@ impl /// `Message`. /// /// [`Checkbox`]: struct.Checkbox.html - pub fn new(is_checked: bool, label: &str, f: F) -> Self + pub fn new(is_checked: bool, label: impl Into, f: F) -> Self where F: 'static + Fn(bool) -> Message, { Checkbox { is_checked, on_toggle: Box::new(f), - label: String::from(label), + label: label.into(), width: Length::Shrink, size: ::DEFAULT_SIZE, spacing: Renderer::DEFAULT_SPACING, -- cgit From 1a9bfd9e737c4203c9ec607465c106da08ad5020 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Sun, 5 Apr 2020 10:29:25 +0700 Subject: Radiobutton label is now `impl Into` --- native/src/widget/radio.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'native/src') diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 8fb3d0cc..bc23c116 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -53,7 +53,12 @@ impl Radio { /// receives the value of the radio and must produce a `Message`. /// /// [`Radio`]: struct.Radio.html - pub fn new(value: V, label: &str, selected: Option, f: F) -> Self + pub fn new( + value: V, + label: impl Into, + selected: Option, + f: F, + ) -> Self where V: Eq + Copy, F: 'static + Fn(V) -> Message, @@ -61,7 +66,7 @@ impl Radio { Radio { is_selected: Some(value) == selected, on_click: f(value), - label: String::from(label), + label: label.into(), style: Renderer::Style::default(), } } -- cgit