diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 800254ed..c9678b9d 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -530,7 +530,7 @@ impl<'a> Step { |choices, language| { choices.push(Radio::new( language, - language.into(), + language, selection, StepMessage::LanguageSelected, )) @@ -729,16 +729,16 @@ impl Language { } } -impl From for &str { - fn from(language: Language) -> &'static str { - match language { +impl From for String { + fn from(language: Language) -> String { + String::from(match language { Language::Rust => "Rust", Language::Elm => "Elm", Language::Ruby => "Ruby", Language::Haskell => "Haskell", Language::C => "C", Language::Other => "Other", - } + }) } } 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, 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(), } }