From 67fd107746104d1d68d9b4a81a6be782c1f15a54 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 13 Apr 2020 22:19:47 -0700 Subject: [PATCH 1/3] Fix tour example --- examples/tour/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index c9678b9d..918238b6 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, + &String::from(language), selection, StepMessage::LanguageSelected, )) From f7825fd93620c1c1a8d26aa81337da4df24b49a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 14 Apr 2020 07:41:35 +0200 Subject: [PATCH 2/3] Fix `Checkbox` and `Radio` API in `iced_web` --- examples/tour/src/main.rs | 2 +- web/src/widget/checkbox.rs | 4 ++-- web/src/widget/radio.rs | 9 +++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 918238b6..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, - &String::from(language), + language, selection, StepMessage::LanguageSelected, )) 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 Checkbox { /// `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: 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 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, @@ -57,7 +62,7 @@ impl Radio { Radio { is_selected: Some(value) == selected, on_click: f(value), - label: String::from(label), + label: label.into(), style: Default::default(), } } From 88b7dd66012dd9dc5aca6d07c4346f48775cee91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 14 Apr 2020 07:44:04 +0200 Subject: [PATCH 3/3] Check Wasm compilation of `tour` example in CI --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c5ded3a..520d8da9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,3 +27,5 @@ jobs: - uses: actions/checkout@master - name: Run checks run: cargo check --package iced --target wasm32-unknown-unknown + - name: Check compilation of `tour` example + run: cargo build --package tour --target wasm32-unknown-unknown