summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dmitry Kashitsyn <korvin@deeptown.org>2020-04-05 10:29:25 +0700
committerLibravatar Dmitry Kashitsyn <korvin@deeptown.org>2020-04-05 12:43:18 +0700
commit1a9bfd9e737c4203c9ec607465c106da08ad5020 (patch)
tree531f9692a2dfefcd9505b72eda8ff4a40d1c1e11
parent15f5b93a0d4b7b7fead8d1864c77e6df50b9a231 (diff)
downloadiced-1a9bfd9e737c4203c9ec607465c106da08ad5020.tar.gz
iced-1a9bfd9e737c4203c9ec607465c106da08ad5020.tar.bz2
iced-1a9bfd9e737c4203c9ec607465c106da08ad5020.zip
Radiobutton label is now `impl Into<String>`
Diffstat (limited to '')
-rw-r--r--examples/tour/src/main.rs3
-rw-r--r--native/src/widget/radio.rs9
2 files changed, 9 insertions, 3 deletions
diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs
index 800254ed..0928cf30 100644
--- a/examples/tour/src/main.rs
+++ b/examples/tour/src/main.rs
@@ -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,
))
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<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(),
}
}