From eeb79c0f88a15b31e7ac5933325012f52031eac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20R=C3=B6ssler?= Date: Wed, 9 Feb 2022 12:56:01 +0100 Subject: [PATCH] correctly add egui lints and fix all warnings --- egui_extras/src/datepicker/button.rs | 2 +- egui_extras/src/datepicker/popup.rs | 6 ++--- egui_extras/src/grid.rs | 14 +++++------ egui_extras/src/layout.rs | 7 +++--- egui_extras/src/lib.rs | 36 ++++++++++++++-------------- egui_extras/src/sizing.rs | 2 +- egui_extras/src/table.rs | 6 ++--- 7 files changed, 37 insertions(+), 36 deletions(-) diff --git a/egui_extras/src/datepicker/button.rs b/egui_extras/src/datepicker/button.rs index 8cce4fed..a017a850 100644 --- a/egui_extras/src/datepicker/button.rs +++ b/egui_extras/src/datepicker/button.rs @@ -114,7 +114,7 @@ impl<'a> Widget for DatePickerButton<'a> { calendar: self.calendar, calendar_week: self.calendar_week, } - .draw(ui) + .draw(ui); }) }) .response; diff --git a/egui_extras/src/datepicker/popup.rs b/egui_extras/src/datepicker/popup.rs index e16c0f01..4637b883 100644 --- a/egui_extras/src/datepicker/popup.rs +++ b/egui_extras/src/datepicker/popup.rs @@ -130,7 +130,7 @@ impl<'a> DatePickerPopup<'a> { } }); }); - }) + }); }); } @@ -225,7 +225,7 @@ impl<'a> DatePickerPopup<'a> { } }); }); - }) + }); }); } @@ -343,7 +343,7 @@ impl<'a> DatePickerPopup<'a> { } }); }); - }) + }); }); }); diff --git a/egui_extras/src/grid.rs b/egui_extras/src/grid.rs index c4c91c64..1bf619bb 100644 --- a/egui_extras/src/grid.rs +++ b/egui_extras/src/grid.rs @@ -18,7 +18,7 @@ pub struct GridBuilder<'a> { impl<'a> GridBuilder<'a> { /// Create new grid builder - /// After adding size hints with [Self::column]/[Self::columns] the grid can be build with [Self::horizontal]/[Self::vertical] + /// After adding size hints with `[Self::column]`/`[Self::columns]` the grid can be build with `[Self::horizontal]`/`[Self::vertical]` pub fn new(ui: &'a mut Ui, padding: Padding) -> Self { let sizing = Sizing::new(); @@ -38,7 +38,7 @@ impl<'a> GridBuilder<'a> { /// Add size hint for columns/rows [count] times pub fn sizes(mut self, size: Size, count: usize) -> Self { for _ in 0..count { - self.sizing.add_size(size.clone()); + self.sizing.add_size(size); } self } @@ -134,20 +134,20 @@ impl<'a, 'b> Grid<'a, 'b> { self._cell(false, add_contents); } - pub fn _grid(&mut self, clip: bool, grid_builder: impl FnOnce(GridBuilder)) { + pub fn _grid(&mut self, clip: bool, grid_builder: impl FnOnce(GridBuilder<'_>)) { let padding = self.padding.clone(); self._cell(clip, |ui| { grid_builder(GridBuilder::new(ui, padding)); }); } /// Add grid as cell, content is clipped - pub fn grid(&mut self, grid_builder: impl FnOnce(GridBuilder)) { - self._grid(true, grid_builder) + pub fn grid(&mut self, grid_builder: impl FnOnce(GridBuilder<'_>)) { + self._grid(true, grid_builder); } /// Add grid as cell, content is not clipped - pub fn grid_noclip(&mut self, grid_builder: impl FnOnce(GridBuilder)) { - self._grid(false, grid_builder) + pub fn grid_noclip(&mut self, grid_builder: impl FnOnce(GridBuilder<'_>)) { + self._grid(false, grid_builder); } } diff --git a/egui_extras/src/layout.rs b/egui_extras/src/layout.rs index 16a1b5b1..9636c8e4 100644 --- a/egui_extras/src/layout.rs +++ b/egui_extras/src/layout.rs @@ -1,6 +1,7 @@ use crate::Padding; use egui::{Pos2, Rect, Response, Rgba, Sense, Ui, Vec2}; +#[derive(Clone, Copy)] pub(crate) enum CellSize { /// Absolute size in points Absolute(f32), @@ -15,7 +16,7 @@ pub(crate) enum LineDirection { TopToBottom, } -/// Positions cells in [LineDirection] and starts a new line on [Layout::end_line] +/// Positions cells in `[LineDirection]` and starts a new line on `[Layout::end_line]` pub struct Layout<'l> { ui: &'l mut Ui, padding: Padding, @@ -153,12 +154,12 @@ impl<'l> Layout<'l> { child_ui.set_clip_rect(clip_rect); } - add_contents(&mut child_ui) + add_contents(&mut child_ui); } } impl<'a> Drop for Layout<'a> { fn drop(&mut self) { - self.set_rect() + self.set_rect(); } } diff --git a/egui_extras/src/lib.rs b/egui_extras/src/lib.rs index d1327a4e..ecccace0 100644 --- a/egui_extras/src/lib.rs +++ b/egui_extras/src/lib.rs @@ -1,21 +1,3 @@ -#[cfg(feature = "chrono")] -mod datepicker; - -mod grid; -mod layout; -mod padding; -mod sizing; -mod table; - -#[cfg(feature = "chrono")] -pub use datepicker::DatePickerButton; - -pub use grid::*; -pub(crate) use layout::Layout; -pub use padding::Padding; -pub use sizing::Size; -pub use table::*; - #![forbid(unsafe_code)] #![warn( clippy::all, @@ -95,3 +77,21 @@ pub use table::*; )] #![allow(clippy::float_cmp)] #![allow(clippy::manual_range_contains)] + +#[cfg(feature = "chrono")] +mod datepicker; + +mod grid; +mod layout; +mod padding; +mod sizing; +mod table; + +#[cfg(feature = "chrono")] +pub use datepicker::DatePickerButton; + +pub use grid::*; +pub(crate) use layout::Layout; +pub use padding::Padding; +pub use sizing::Size; +pub use table::*; diff --git a/egui_extras/src/sizing.rs b/egui_extras/src/sizing.rs index ec7c7dad..6d8c70ce 100644 --- a/egui_extras/src/sizing.rs +++ b/egui_extras/src/sizing.rs @@ -1,5 +1,5 @@ /// Size hint for table column/grid cell -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Copy)] pub enum Size { /// Absolute size in points Absolute(f32), diff --git a/egui_extras/src/table.rs b/egui_extras/src/table.rs index a6078d15..283a54f9 100644 --- a/egui_extras/src/table.rs +++ b/egui_extras/src/table.rs @@ -53,7 +53,7 @@ impl<'a> TableBuilder<'a> { /// Add size hint for column [count] times pub fn columns(mut self, size: Size, count: usize) -> Self { for _ in 0..count { - self.sizing.add_size(size.clone()); + self.sizing.add_size(size); } self } @@ -105,7 +105,7 @@ impl<'a> TableBuilder<'a> { scroll: self.scroll, striped: self.striped, } - .body(body) + .body(body); } } @@ -157,7 +157,7 @@ pub struct TableBody<'a> { impl<'a> TableBody<'a> { /// Add rows with same height /// Is a lot more performant than adding each individual row as non visible rows must not be rendered - pub fn rows(mut self, height: f32, rows: usize, mut row: impl FnMut(usize, TableRow)) { + pub fn rows(mut self, height: f32, rows: usize, mut row: impl FnMut(usize, TableRow<'_, '_>)) { let delta = self.layout.current_y() - self.start_y; let mut start = 0;