From 8d504612cbfe62ce21f575b0896e21b1ef94c51d Mon Sep 17 00:00:00 2001 From: Marrub Date: Sat, 9 Mar 2019 17:48:55 -0500 Subject: [PATCH] clippy saves the day part 4 --- source/durandal/bin.rs | 6 +++--- source/durandal/bit.rs | 2 +- source/durandal/fixed.rs | 1 + source/marathon/map.rs | 2 +- source/marathon/shp.rs | 8 ++++---- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/source/durandal/bin.rs b/source/durandal/bin.rs index f99650a..6f15769 100644 --- a/source/durandal/bin.rs +++ b/source/durandal/bin.rs @@ -383,7 +383,7 @@ impl OptU16 /// /// assert_eq!(OptU16::none(), OptU16::from_repr(u16::max_value())); /// ``` - pub const fn none() -> Self {OptU16(None)} + pub const fn none() -> Self {Self(None)} /// Creates an `OptU16` from a `u16`. pub fn from_repr(n: u16) -> Self @@ -408,7 +408,7 @@ impl OptU16 /// assert_eq!(OptU16::from_repr(u16max).get_repr(), u16max); /// assert_eq!(OptU16::from_repr(0u16).get_repr(), 0u16); /// ``` - pub fn get_repr(&self) -> u16 + pub fn get_repr(self) -> u16 { match self.0 { None => u16::max_value(), @@ -427,7 +427,7 @@ impl OptU16 /// assert_eq!(OptU16::from_repr(u16::max_value()).get(), None); /// assert_eq!(OptU16::from_repr(0u16).get(), Some(0u16)); /// ``` - pub fn get(&self) -> Option + pub fn get(self) -> Option { match self.0 { None => None, diff --git a/source/durandal/bit.rs b/source/durandal/bit.rs index 327db69..72dea3d 100644 --- a/source/durandal/bit.rs +++ b/source/durandal/bit.rs @@ -27,7 +27,7 @@ pub fn read_bits(b: &[u8], cr_ptr: usize, width: u8) -> ResultS<(usize, u64)> let first_bits = cr_ptr as u32 % 8; let last_bits = nx_ptr as u32 % 8; - let last_mask = ((1u128 << last_bits) - 1) as u64; + let last_mask = ((1_u128 << last_bits) - 1) as u64; let num_bytes = last_byte - first_byte; diff --git a/source/durandal/fixed.rs b/source/durandal/fixed.rs index e946101..e70d5a5 100644 --- a/source/durandal/fixed.rs +++ b/source/durandal/fixed.rs @@ -1,4 +1,5 @@ //! Fixed point numbers. +#![allow(clippy::use_self)] use std::{fmt::{self, Write}, ops::*}; diff --git a/source/marathon/map.rs b/source/marathon/map.rs index 5ba5c9b..7d4a9d8 100644 --- a/source/marathon/map.rs +++ b/source/marathon/map.rs @@ -499,7 +499,7 @@ impl Default for Minf { fn default() -> Self { - Minf{texture_id: 0, + Self{texture_id: 0, physics_id: 1, skypict_id: 0, miss_flags: MsnFlags::empty(), diff --git a/source/marathon/shp.rs b/source/marathon/shp.rs index 235ac7a..276ffc1 100644 --- a/source/marathon/shp.rs +++ b/source/marathon/shp.rs @@ -286,7 +286,7 @@ impl Color for ColorShp { match *self { ColorShp::Translucent => 0, - ColorShp::Opaque{r, ..} => r, + ColorShp::Opaque{r, ..} | ColorShp::Lit {r, ..} => r, } } @@ -295,7 +295,7 @@ impl Color for ColorShp { match *self { ColorShp::Translucent => 0, - ColorShp::Opaque{g, ..} => g, + ColorShp::Opaque{g, ..} | ColorShp::Lit {g, ..} => g, } } @@ -304,7 +304,7 @@ impl Color for ColorShp { match *self { ColorShp::Translucent => 0, - ColorShp::Opaque{b, ..} => b, + ColorShp::Opaque{b, ..} | ColorShp::Lit {b, ..} => b, } } @@ -313,7 +313,7 @@ impl Color for ColorShp { match *self { ColorShp::Translucent => 0, - ColorShp::Opaque{..} => u16::max_value(), + ColorShp::Opaque{..} | ColorShp::Lit {..} => u16::max_value(), } }