Radiobutton label is now impl Into<String>

This commit is contained in:
Dmitry Kashitsyn 2020-04-05 10:29:25 +07:00
parent 15f5b93a0d
commit 1a9bfd9e73
No known key found for this signature in database
GPG Key ID: 7984C21B77FCB244
2 changed files with 9 additions and 3 deletions

View File

@ -528,9 +528,10 @@ impl<'a> Step {
.push(Language::all().iter().cloned().fold(
Column::new().padding(10).spacing(20),
|choices, language| {
let label: &str = language.into();
choices.push(Radio::new(
language,
language.into(),
label,
selection,
StepMessage::LanguageSelected,
))

View File

@ -53,7 +53,12 @@ impl<Message, Renderer: self::Renderer> Radio<Message, Renderer> {
/// receives the value of the radio and must produce a `Message`.
///
/// [`Radio`]: struct.Radio.html
pub fn new<F, V>(value: V, label: &str, selected: Option<V>, f: F) -> Self
pub fn new<F, V>(
value: V,
label: impl Into<String>,
selected: Option<V>,
f: F,
) -> Self
where
V: Eq + Copy,
F: 'static + Fn(V) -> Message,
@ -61,7 +66,7 @@ impl<Message, Renderer: self::Renderer> Radio<Message, Renderer> {
Radio {
is_selected: Some(value) == selected,
on_click: f(value),
label: String::from(label),
label: label.into(),
style: Renderer::Style::default(),
}
}