diff options
author | 2023-03-14 11:11:17 +0100 | |
---|---|---|
committer | 2023-03-14 11:11:17 +0100 | |
commit | 1816c985fad2ead8dc1e7b62dc8e4bafeed856b2 (patch) | |
tree | 09fc36e95e99939842cf14c79d4a08baf9a2da1f | |
parent | 8f14b448d263a2cfd03a998b1d54c21e33d58980 (diff) | |
download | iced-1816c985fad2ead8dc1e7b62dc8e4bafeed856b2.tar.gz iced-1816c985fad2ead8dc1e7b62dc8e4bafeed856b2.tar.bz2 iced-1816c985fad2ead8dc1e7b62dc8e4bafeed856b2.zip |
Fix `clippy` lints for Rust 1.68
-rw-r--r-- | core/src/font.rs | 9 | ||||
-rw-r--r-- | core/src/mouse/interaction.rs | 9 | ||||
-rw-r--r-- | examples/pick_list/src/main.rs | 9 | ||||
-rw-r--r-- | examples/todos/src/main.rs | 11 | ||||
-rw-r--r-- | graphics/src/primitive.rs | 9 | ||||
-rw-r--r-- | graphics/src/widget/canvas/cache.rs | 7 | ||||
-rw-r--r-- | graphics/src/widget/canvas/stroke.rs | 18 |
7 files changed, 18 insertions, 54 deletions
diff --git a/core/src/font.rs b/core/src/font.rs index 3f9ad2b5..d8c34e5a 100644 --- a/core/src/font.rs +++ b/core/src/font.rs @@ -1,10 +1,11 @@ /// A font. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, Default)] pub enum Font { /// The default font. /// /// This is normally a font configured in a renderer or loaded from the /// system. + #[default] Default, /// An external font. @@ -16,9 +17,3 @@ pub enum Font { bytes: &'static [u8], }, } - -impl Default for Font { - fn default() -> Font { - Font::Default - } -} diff --git a/core/src/mouse/interaction.rs b/core/src/mouse/interaction.rs index 664147a7..57da93fe 100644 --- a/core/src/mouse/interaction.rs +++ b/core/src/mouse/interaction.rs @@ -1,7 +1,8 @@ /// The interaction of a mouse cursor. -#[derive(Debug, Eq, PartialEq, Clone, Copy, PartialOrd, Ord)] +#[derive(Debug, Eq, PartialEq, Clone, Copy, PartialOrd, Ord, Default)] #[allow(missing_docs)] pub enum Interaction { + #[default] Idle, Pointer, Grab, @@ -12,9 +13,3 @@ pub enum Interaction { ResizingHorizontally, ResizingVertically, } - -impl Default for Interaction { - fn default() -> Interaction { - Interaction::Idle - } -} diff --git a/examples/pick_list/src/main.rs b/examples/pick_list/src/main.rs index 62a4ef88..21200621 100644 --- a/examples/pick_list/src/main.rs +++ b/examples/pick_list/src/main.rs @@ -61,8 +61,9 @@ impl Sandbox for Example { } } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub enum Language { + #[default] Rust, Elm, Ruby, @@ -84,12 +85,6 @@ impl Language { ]; } -impl Default for Language { - fn default() -> Language { - Language::Rust - } -} - impl std::fmt::Display for Language { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 6a87f58c..6361667e 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -435,19 +435,16 @@ fn view_controls(tasks: &[Task], current_filter: Filter) -> Element<Message> { .into() } -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive( + Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, +)] pub enum Filter { + #[default] All, Active, Completed, } -impl Default for Filter { - fn default() -> Self { - Filter::All - } -} - impl Filter { fn matches(&self, task: &Task) -> bool { match self { diff --git a/graphics/src/primitive.rs b/graphics/src/primitive.rs index 5a163a2f..cef422a2 100644 --- a/graphics/src/primitive.rs +++ b/graphics/src/primitive.rs @@ -9,9 +9,10 @@ use crate::triangle; use std::sync::Arc; /// A rendering primitive. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] pub enum Primitive { /// An empty primitive + #[default] None, /// A group of primitives Group { @@ -117,9 +118,3 @@ pub enum Primitive { cache: Arc<Primitive>, }, } - -impl Default for Primitive { - fn default() -> Primitive { - Primitive::None - } -} diff --git a/graphics/src/widget/canvas/cache.rs b/graphics/src/widget/canvas/cache.rs index 52217bbb..678b0f92 100644 --- a/graphics/src/widget/canvas/cache.rs +++ b/graphics/src/widget/canvas/cache.rs @@ -4,7 +4,9 @@ use crate::Primitive; use iced_native::Size; use std::{cell::RefCell, sync::Arc}; +#[derive(Default)] enum State { + #[default] Empty, Filled { bounds: Size, @@ -12,11 +14,6 @@ enum State { }, } -impl Default for State { - fn default() -> Self { - State::Empty - } -} /// A simple cache that stores generated [`Geometry`] to avoid recomputation. /// /// A [`Cache`] will not redraw its geometry unless the dimensions of its layer diff --git a/graphics/src/widget/canvas/stroke.rs b/graphics/src/widget/canvas/stroke.rs index 4c19251d..49f5701c 100644 --- a/graphics/src/widget/canvas/stroke.rs +++ b/graphics/src/widget/canvas/stroke.rs @@ -59,9 +59,10 @@ impl<'a> Default for Stroke<'a> { } /// The shape used at the end of open subpaths when they are stroked. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, Default)] pub enum LineCap { /// The stroke for each sub-path does not extend beyond its two endpoints. + #[default] Butt, /// At the end of each sub-path, the shape representing the stroke will be /// extended by a square. @@ -71,12 +72,6 @@ pub enum LineCap { Round, } -impl Default for LineCap { - fn default() -> LineCap { - LineCap::Butt - } -} - impl From<LineCap> for lyon::tessellation::LineCap { fn from(line_cap: LineCap) -> lyon::tessellation::LineCap { match line_cap { @@ -89,9 +84,10 @@ impl From<LineCap> for lyon::tessellation::LineCap { /// The shape used at the corners of paths or basic shapes when they are /// stroked. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, Default)] pub enum LineJoin { /// A sharp corner. + #[default] Miter, /// A round corner. Round, @@ -99,12 +95,6 @@ pub enum LineJoin { Bevel, } -impl Default for LineJoin { - fn default() -> LineJoin { - LineJoin::Miter - } -} - impl From<LineJoin> for lyon::tessellation::LineJoin { fn from(line_join: LineJoin) -> lyon::tessellation::LineJoin { match line_join { |