From 948d8ec6ed50255a6c2cd54507cbff9b370d4fe3 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 2 Jan 2021 16:31:45 +0100 Subject: [PATCH] clippy fixes --- egui/src/context.rs | 2 ++ egui/src/lib.rs | 1 + egui/src/paint/font.rs | 2 +- egui/src/paint/texture_atlas.rs | 2 +- egui/src/ui.rs | 6 +++++- egui/src/util/history.rs | 4 ++-- egui_glium/src/lib.rs | 2 +- 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/egui/src/context.rs b/egui/src/context.rs index 2e1f85d4..04987839 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -1,3 +1,5 @@ +// #![warn(missing_docs)] + use std::sync::{ atomic::{AtomicU32, Ordering::SeqCst}, Arc, diff --git a/egui/src/lib.rs b/egui/src/lib.rs index 2e3373fd..3401ba46 100644 --- a/egui/src/lib.rs +++ b/egui/src/lib.rs @@ -76,6 +76,7 @@ rust_2018_idioms, unused_doc_comments, )] +#![allow(clippy::manual_range_contains)] pub mod align; mod animation_manager; diff --git a/egui/src/paint/font.rs b/egui/src/paint/font.rs index c4313819..94411f0c 100644 --- a/egui/src/paint/font.rs +++ b/egui/src/paint/font.rs @@ -365,7 +365,7 @@ impl Font { mut first_row_indentation: f32, max_width_in_points: f32, ) -> Vec { - if text == "" { + if text.is_empty() { return vec![Row { x_offsets: vec![first_row_indentation], y_min: 0.0, diff --git a/egui/src/paint/texture_atlas.rs b/egui/src/paint/texture_atlas.rs index 2b06db6f..ea52b469 100644 --- a/egui/src/paint/texture_atlas.rs +++ b/egui/src/paint/texture_atlas.rs @@ -13,7 +13,7 @@ pub struct Texture { impl Texture { /// Returns the textures as `sRGBA` premultiplied pixels, row by row, top to bottom. - pub fn srgba_pixels<'slf>(&'slf self) -> impl Iterator + 'slf { + pub fn srgba_pixels(&'_ self) -> impl Iterator + '_ { use super::Srgba; let srgba_from_luminance_lut: Vec = (0..=255).map(Srgba::white_alpha).collect(); self.pixels diff --git a/egui/src/ui.rs b/egui/src/ui.rs index 3e436e50..5c6f9753 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -1,4 +1,4 @@ -#![allow(clippy::float_cmp)] +// #![warn(missing_docs)] use std::{hash::Hash, sync::Arc}; @@ -231,6 +231,7 @@ impl Ui { /// Set the maximum width of the ui. /// You won't be able to shrink it below the current minimum size. pub fn set_max_width(&mut self, width: f32) { + #![allow(clippy::float_cmp)] if self.layout.main_dir() == Direction::RightToLeft { debug_assert_eq!(self.min_rect().max.x, self.max_rect().max.x); self.region.max_rect.min.x = @@ -245,6 +246,7 @@ impl Ui { /// Set the maximum height of the ui. /// You won't be able to shrink it below the current minimum size. pub fn set_max_height(&mut self, height: f32) { + #![allow(clippy::float_cmp)] if self.layout.main_dir() == Direction::BottomUp { debug_assert_eq!(self.min_rect().max.y, self.region.max_rect.max.y); self.region.max_rect.min.y = @@ -268,6 +270,7 @@ impl Ui { /// Set the minimum width of the ui. /// This can't shrink the ui, only make it larger. pub fn set_min_width(&mut self, width: f32) { + #![allow(clippy::float_cmp)] if self.layout.main_dir() == Direction::RightToLeft { debug_assert_eq!(self.region.min_rect.max.x, self.region.max_rect.max.x); let min_rect = &mut self.region.min_rect; @@ -283,6 +286,7 @@ impl Ui { /// Set the minimum height of the ui. /// This can't shrink the ui, only make it larger. pub fn set_min_height(&mut self, height: f32) { + #![allow(clippy::float_cmp)] if self.layout.main_dir() == Direction::BottomUp { debug_assert_eq!(self.region.min_rect.max.y, self.region.max_rect.max.y); let min_rect = &mut self.region.min_rect; diff --git a/egui/src/util/history.rs b/egui/src/util/history.rs index 67bfb55a..fdefab63 100644 --- a/egui/src/util/history.rs +++ b/egui/src/util/history.rs @@ -89,11 +89,11 @@ where /// `(time, value)` pairs /// Time difference between values can be zero, but never negative. // TODO: impl IntoIter - pub fn iter<'a>(&'a self) -> impl Iterator + 'a { + pub fn iter(&'_ self) -> impl Iterator + '_ { self.values.iter().map(|(time, value)| (*time, *value)) } - pub fn values<'a>(&'a self) -> impl Iterator + 'a { + pub fn values(&'_ self) -> impl Iterator + '_ { self.values.iter().map(|(_time, value)| *value) } diff --git a/egui_glium/src/lib.rs b/egui_glium/src/lib.rs index 4ace91cc..50a33031 100644 --- a/egui_glium/src/lib.rs +++ b/egui_glium/src/lib.rs @@ -7,7 +7,7 @@ #![forbid(unsafe_code)] #![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds #![warn(clippy::all, rust_2018_idioms)] -#![allow(clippy::single_match)] +#![allow(clippy::manual_range_contains, clippy::single_match)] mod backend; #[cfg(feature = "http")]