diff --git a/src/native/cupertino/cupertino_alert.rs b/src/native/cupertino/cupertino_alert.rs index 132ea0b6..4e2eb4f1 100644 --- a/src/native/cupertino/cupertino_alert.rs +++ b/src/native/cupertino/cupertino_alert.rs @@ -1,3 +1,5 @@ +#![allow(clippy::todo)] + use iced_native::{ alignment, event::Status, @@ -158,8 +160,8 @@ where width: Length::Fixed(400.0), height: Length::Fixed(200.0), is_hidden: true, - title: "Title".to_string(), - content: "Content".to_string(), + title: "Title".to_owned(), + content: "Content".to_owned(), actions: vec![], backdrop: None, on_escape: None, @@ -244,7 +246,7 @@ where { let as_text_element = element.into().font(SF_UI_ROUNDED); - return Element::from(as_text_element); + Element::from(as_text_element) } } @@ -257,36 +259,36 @@ where ::Font: From, { fn width(&self) -> Length { - if !self.is_hidden { - self.width - } else { + if self.is_hidden { Length::Fixed(0.0) + } else { + self.width } } fn height(&self) -> Length { - if !self.is_hidden { - self.height - } else { + if self.is_hidden { Length::Fixed(0.0) + } else { + self.height } } fn layout(&self, _renderer: &Renderer, limits: &Limits) -> Node { - return Node::new( + Node::new( limits - .width(if !self.is_hidden { - self.width - } else { + .width(if self.is_hidden { Length::Fixed(0.0) - }) - .height(if !self.is_hidden { - self.height } else { + self.width + }) + .height(if self.is_hidden { Length::Fixed(0.0) + } else { + self.height }) .resolve(Size::new(f32::INFINITY, f32::INFINITY)), - ); + ) } fn draw( @@ -544,7 +546,12 @@ where if hit_x.contains(&cursor_position.x) && hit_y.contains(&cursor_position.y) { - shell.publish(self.actions[0].on_pressed.clone().unwrap()); + shell.publish( + self.actions[0] + .on_pressed + .clone() + .expect("Unable to retrieve the left button click message"), + ); } } @@ -557,7 +564,12 @@ where if hit_x.contains(&cursor_position.x) && hit_y.contains(&cursor_position.y) { - shell.publish(self.actions[1].on_pressed.clone().unwrap()); + shell.publish( + self.actions[1] + .on_pressed + .clone() + .expect("Unable to retrieve the right button click message"), + ); } } } @@ -569,7 +581,11 @@ where if !hit_x.contains(&cursor_position.x) || !hit_y.contains(&cursor_position.y) { if self.backdrop.is_some() { - shell.publish(self.backdrop.clone().unwrap()); + shell.publish( + self.backdrop + .clone() + .expect("Unable to retrieve the backdrop message"), + ); } // Default behaviour: hide the modal after clicking on the backdrop // @@ -581,20 +597,23 @@ where if key_code == keyboard::KeyCode::Escape && self.on_escape.is_some() { self.is_hidden = true; - shell.publish(self.on_escape.clone().unwrap()); + shell.publish( + self.on_escape + .clone() + .expect("Unable to retrieve the escape message"), + ); return Status::Captured; - } else { - return Status::Ignored; } } _ => return Status::Ignored, } - return Status::Ignored; + Status::Ignored } } +#[allow(clippy::type_repetition_in_bounds)] impl<'a, Message, Renderer: 'a> From> for Element<'a, Message, Renderer> where diff --git a/src/native/cupertino/cupertino_button.rs b/src/native/cupertino/cupertino_button.rs index 63ee6a66..2abe7b12 100644 --- a/src/native/cupertino/cupertino_button.rs +++ b/src/native/cupertino/cupertino_button.rs @@ -107,6 +107,7 @@ where } /// Sets the `colour` of the [`CupertinoButton`](CupertinoButton). + #[must_use] pub fn colour(mut self, colour: Option) -> Self { self.colour = colour; self @@ -180,7 +181,7 @@ where new_style.clone_from(style); if self.colour.is_some() { - new_style.text_color = self.colour.unwrap(); + new_style.text_color = self.colour.expect("Unable to retrieve the text colour"); } else if self.is_filled && self.on_pressed.is_some() { new_style.text_color = Color::WHITE; } else if !self.is_filled && self.on_pressed.is_some() { @@ -199,7 +200,7 @@ where layout, cursor_position, viewport, - ) + ); } fn on_event( @@ -225,7 +226,11 @@ where .contains(&cursor_position.y); if hit_x && hit_y { - shell.publish(self.on_pressed.clone().unwrap()); + shell.publish( + self.on_pressed + .clone() + .expect("Unable to retrieve the pressed message"), + ); return Status::Captured; } } @@ -234,7 +239,7 @@ where _ => {} } - return Status::Ignored; + Status::Ignored } } diff --git a/src/native/cupertino/cupertino_switch.rs b/src/native/cupertino/cupertino_switch.rs index 1d61a338..1c33a546 100644 --- a/src/native/cupertino/cupertino_switch.rs +++ b/src/native/cupertino/cupertino_switch.rs @@ -167,7 +167,7 @@ where } } -impl<'a, Message, B, T> Widget> for CupertinoSwitch +impl Widget> for CupertinoSwitch where B: Backend, Message: Clone, @@ -180,12 +180,12 @@ where } fn layout(&self, _renderer: &Renderer, limits: &Limits) -> Node { - return Node::new( + Node::new( limits .width(self.width) .height(self.height) .resolve(Size::new(f32::INFINITY, f32::INFINITY)), - ); + ) } fn draw( @@ -386,7 +386,12 @@ where state.animation_frame = 0; if self.on_changed.as_ref().is_some() { - shell.publish((self.on_changed.as_ref().unwrap())(!self.value)); + shell.publish((self + .on_changed + .as_ref() + .expect("Unable to retrieve the changed message"))( + !self.value + )); state.prev_value = self.value; state.published = true; @@ -399,7 +404,7 @@ where _ => {} } - return Status::Ignored; + Status::Ignored } fn overlay<'b>( @@ -412,7 +417,7 @@ where state.bounds = layout.bounds(); - return None; + None } }