summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-04-14 07:41:35 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-04-14 07:41:35 +0200
commitf7825fd93620c1c1a8d26aa81337da4df24b49a0 (patch)
tree826f9dc395c9aceed5b6f009c99b843d638fc6bc /web
parent67fd107746104d1d68d9b4a81a6be782c1f15a54 (diff)
downloadiced-f7825fd93620c1c1a8d26aa81337da4df24b49a0.tar.gz
iced-f7825fd93620c1c1a8d26aa81337da4df24b49a0.tar.bz2
iced-f7825fd93620c1c1a8d26aa81337da4df24b49a0.zip
Fix `Checkbox` and `Radio` API in `iced_web`
Diffstat (limited to 'web')
-rw-r--r--web/src/widget/checkbox.rs4
-rw-r--r--web/src/widget/radio.rs9
2 files changed, 9 insertions, 4 deletions
diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs
index 0657ccfb..5ebc26c8 100644
--- a/web/src/widget/checkbox.rs
+++ b/web/src/widget/checkbox.rs
@@ -43,14 +43,14 @@ impl<Message> Checkbox<Message> {
/// `Message`.
///
/// [`Checkbox`]: struct.Checkbox.html
- pub fn new<F>(is_checked: bool, label: &str, f: F) -> Self
+ pub fn new<F>(is_checked: bool, label: impl Into<String>, f: F) -> Self
where
F: 'static + Fn(bool) -> Message,
{
Checkbox {
is_checked,
on_toggle: Rc::new(f),
- label: String::from(label),
+ label: label.into(),
width: Length::Shrink,
style: Default::default(),
}
diff --git a/web/src/widget/radio.rs b/web/src/widget/radio.rs
index e00e26db..520b24cd 100644
--- a/web/src/widget/radio.rs
+++ b/web/src/widget/radio.rs
@@ -49,7 +49,12 @@ impl<Message> Radio<Message> {
/// 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,
@@ -57,7 +62,7 @@ impl<Message> Radio<Message> {
Radio {
is_selected: Some(value) == selected,
on_click: f(value),
- label: String::from(label),
+ label: label.into(),
style: Default::default(),
}
}