From d8536e62484a2f46d0ad9b49b7141f6507d663e3 Mon Sep 17 00:00:00 2001 From: 13r0ck Date: Tue, 3 Jan 2023 11:23:58 -0700 Subject: [PATCH 1/2] use same name & order for checkbox::new and helper The helper function for the checkbox widget switched the order and name of the arguments passed when creating the checkbox widget. This just standardizes the order whether the dev is using the helper or the associated function. Continuation of https://github.com/iced-rs/iced/pull/1616 --- native/src/widget/checkbox.rs | 2 +- native/src/widget/helpers.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index bec5c44807..96fd60ba4a 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -67,7 +67,7 @@ where /// * a function that will be called when the [`Checkbox`] is toggled. It /// will receive the new state of the [`Checkbox`] and must produce a /// `Message`. - pub fn new(is_checked: bool, label: impl Into, f: F) -> Self + pub fn new(label: impl Into, is_checked: bool, f: F) -> Self where F: 'a + Fn(bool) -> Message, { diff --git a/native/src/widget/helpers.rs b/native/src/widget/helpers.rs index 5b241f8397..dfd949f6a9 100644 --- a/native/src/widget/helpers.rs +++ b/native/src/widget/helpers.rs @@ -129,7 +129,7 @@ where Renderer: crate::text::Renderer, Renderer::Theme: widget::checkbox::StyleSheet + widget::text::StyleSheet, { - widget::Checkbox::new(is_checked, label, f) + widget::Checkbox::new(label, is_checked, f) } /// Creates a new [`Radio`]. From 2209dbf2124159a9a6362c06aef250b76294197c Mon Sep 17 00:00:00 2001 From: 13r0ck Date: Wed, 4 Jan 2023 13:08:53 -0700 Subject: [PATCH 2/2] Checkbox: Fix tests with sync'ed helper macro and associated fn --- native/src/widget/checkbox.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 96fd60ba4a..b46433c256 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -27,7 +27,7 @@ pub use iced_style::checkbox::{Appearance, StyleSheet}; /// /// let is_checked = true; /// -/// Checkbox::new(is_checked, "Toggle me!", Message::CheckboxToggled); +/// Checkbox::new("Toggle me!", is_checked, Message::CheckboxToggled); /// ``` /// /// ![Checkbox drawn by `iced_wgpu`](https://github.com/iced-rs/iced/blob/7760618fb112074bc40b148944521f312152012a/docs/images/checkbox.png?raw=true)