clippy fixes

This commit is contained in:
Emil Ernerfeldt 2021-01-02 16:31:45 +01:00
parent 2b2b9d5d28
commit 948d8ec6ed
7 changed files with 13 additions and 6 deletions

View file

@ -1,3 +1,5 @@
// #![warn(missing_docs)]
use std::sync::{ use std::sync::{
atomic::{AtomicU32, Ordering::SeqCst}, atomic::{AtomicU32, Ordering::SeqCst},
Arc, Arc,

View file

@ -76,6 +76,7 @@
rust_2018_idioms, rust_2018_idioms,
unused_doc_comments, unused_doc_comments,
)] )]
#![allow(clippy::manual_range_contains)]
pub mod align; pub mod align;
mod animation_manager; mod animation_manager;

View file

@ -365,7 +365,7 @@ impl Font {
mut first_row_indentation: f32, mut first_row_indentation: f32,
max_width_in_points: f32, max_width_in_points: f32,
) -> Vec<Row> { ) -> Vec<Row> {
if text == "" { if text.is_empty() {
return vec![Row { return vec![Row {
x_offsets: vec![first_row_indentation], x_offsets: vec![first_row_indentation],
y_min: 0.0, y_min: 0.0,

View file

@ -13,7 +13,7 @@ pub struct Texture {
impl Texture { impl Texture {
/// Returns the textures as `sRGBA` premultiplied pixels, row by row, top to bottom. /// Returns the textures as `sRGBA` premultiplied pixels, row by row, top to bottom.
pub fn srgba_pixels<'slf>(&'slf self) -> impl Iterator<Item = super::Srgba> + 'slf { pub fn srgba_pixels(&'_ self) -> impl Iterator<Item = super::Srgba> + '_ {
use super::Srgba; use super::Srgba;
let srgba_from_luminance_lut: Vec<Srgba> = (0..=255).map(Srgba::white_alpha).collect(); let srgba_from_luminance_lut: Vec<Srgba> = (0..=255).map(Srgba::white_alpha).collect();
self.pixels self.pixels

View file

@ -1,4 +1,4 @@
#![allow(clippy::float_cmp)] // #![warn(missing_docs)]
use std::{hash::Hash, sync::Arc}; use std::{hash::Hash, sync::Arc};
@ -231,6 +231,7 @@ impl Ui {
/// Set the maximum width of the ui. /// Set the maximum width of the ui.
/// You won't be able to shrink it below the current minimum size. /// You won't be able to shrink it below the current minimum size.
pub fn set_max_width(&mut self, width: f32) { pub fn set_max_width(&mut self, width: f32) {
#![allow(clippy::float_cmp)]
if self.layout.main_dir() == Direction::RightToLeft { if self.layout.main_dir() == Direction::RightToLeft {
debug_assert_eq!(self.min_rect().max.x, self.max_rect().max.x); debug_assert_eq!(self.min_rect().max.x, self.max_rect().max.x);
self.region.max_rect.min.x = self.region.max_rect.min.x =
@ -245,6 +246,7 @@ impl Ui {
/// Set the maximum height of the ui. /// Set the maximum height of the ui.
/// You won't be able to shrink it below the current minimum size. /// You won't be able to shrink it below the current minimum size.
pub fn set_max_height(&mut self, height: f32) { pub fn set_max_height(&mut self, height: f32) {
#![allow(clippy::float_cmp)]
if self.layout.main_dir() == Direction::BottomUp { if self.layout.main_dir() == Direction::BottomUp {
debug_assert_eq!(self.min_rect().max.y, self.region.max_rect.max.y); debug_assert_eq!(self.min_rect().max.y, self.region.max_rect.max.y);
self.region.max_rect.min.y = self.region.max_rect.min.y =
@ -268,6 +270,7 @@ impl Ui {
/// Set the minimum width of the ui. /// Set the minimum width of the ui.
/// This can't shrink the ui, only make it larger. /// This can't shrink the ui, only make it larger.
pub fn set_min_width(&mut self, width: f32) { pub fn set_min_width(&mut self, width: f32) {
#![allow(clippy::float_cmp)]
if self.layout.main_dir() == Direction::RightToLeft { if self.layout.main_dir() == Direction::RightToLeft {
debug_assert_eq!(self.region.min_rect.max.x, self.region.max_rect.max.x); debug_assert_eq!(self.region.min_rect.max.x, self.region.max_rect.max.x);
let min_rect = &mut self.region.min_rect; let min_rect = &mut self.region.min_rect;
@ -283,6 +286,7 @@ impl Ui {
/// Set the minimum height of the ui. /// Set the minimum height of the ui.
/// This can't shrink the ui, only make it larger. /// This can't shrink the ui, only make it larger.
pub fn set_min_height(&mut self, height: f32) { pub fn set_min_height(&mut self, height: f32) {
#![allow(clippy::float_cmp)]
if self.layout.main_dir() == Direction::BottomUp { if self.layout.main_dir() == Direction::BottomUp {
debug_assert_eq!(self.region.min_rect.max.y, self.region.max_rect.max.y); debug_assert_eq!(self.region.min_rect.max.y, self.region.max_rect.max.y);
let min_rect = &mut self.region.min_rect; let min_rect = &mut self.region.min_rect;

View file

@ -89,11 +89,11 @@ where
/// `(time, value)` pairs /// `(time, value)` pairs
/// Time difference between values can be zero, but never negative. /// Time difference between values can be zero, but never negative.
// TODO: impl IntoIter // TODO: impl IntoIter
pub fn iter<'a>(&'a self) -> impl Iterator<Item = (f64, T)> + 'a { pub fn iter(&'_ self) -> impl Iterator<Item = (f64, T)> + '_ {
self.values.iter().map(|(time, value)| (*time, *value)) self.values.iter().map(|(time, value)| (*time, *value))
} }
pub fn values<'a>(&'a self) -> impl Iterator<Item = T> + 'a { pub fn values(&'_ self) -> impl Iterator<Item = T> + '_ {
self.values.iter().map(|(_time, value)| *value) self.values.iter().map(|(_time, value)| *value)
} }

View file

@ -7,7 +7,7 @@
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds #![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
#![warn(clippy::all, rust_2018_idioms)] #![warn(clippy::all, rust_2018_idioms)]
#![allow(clippy::single_match)] #![allow(clippy::manual_range_contains, clippy::single_match)]
mod backend; mod backend;
#[cfg(feature = "http")] #[cfg(feature = "http")]