Merge pull request #294 from MrMonotone/patch-1

Fix tour example
This commit is contained in:
Héctor Ramón 2020-04-14 08:04:12 +02:00 committed by GitHub
commit d0ebcdb936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -27,3 +27,5 @@ jobs:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Run checks - name: Run checks
run: cargo check --package iced --target wasm32-unknown-unknown run: cargo check --package iced --target wasm32-unknown-unknown
- name: Check compilation of `tour` example
run: cargo build --package tour --target wasm32-unknown-unknown

View File

@ -43,14 +43,14 @@ impl<Message> Checkbox<Message> {
/// `Message`. /// `Message`.
/// ///
/// [`Checkbox`]: struct.Checkbox.html /// [`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 where
F: 'static + Fn(bool) -> Message, F: 'static + Fn(bool) -> Message,
{ {
Checkbox { Checkbox {
is_checked, is_checked,
on_toggle: Rc::new(f), on_toggle: Rc::new(f),
label: String::from(label), label: label.into(),
width: Length::Shrink, width: Length::Shrink,
style: Default::default(), style: Default::default(),
} }

View File

@ -49,7 +49,12 @@ impl<Message> Radio<Message> {
/// receives the value of the radio and must produce a `Message`. /// receives the value of the radio and must produce a `Message`.
/// ///
/// [`Radio`]: struct.Radio.html /// [`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 where
V: Eq + Copy, V: Eq + Copy,
F: 'static + Fn(V) -> Message, F: 'static + Fn(V) -> Message,
@ -57,7 +62,7 @@ impl<Message> Radio<Message> {
Radio { Radio {
is_selected: Some(value) == selected, is_selected: Some(value) == selected,
on_click: f(value), on_click: f(value),
label: String::from(label), label: label.into(),
style: Default::default(), style: Default::default(),
} }
} }