Skip to content
Myr

clippy

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Oli Scherer · committed by Oli Scherer · parent e3a4165 · Browse files · 3 files+22 added−24 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+22 added−24 removed

  • other:+22 added−24 removed

3 files+22 added−24 removed

modified:serde/src/de/impls.rs+21 added-22 removed
247 unmodified lines
248 fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>249 where250 E: Error,251 {252 if Self::Value::MIN as i64 <= v as i64 && v as i64 <= Self::Value::MAX as i64 {253 Ok(v as Self::Value)254 } else {255 Err(Error::invalid_value(Unexpected::Signed(v as i64), &self))256 }252 Self::Value::try_from(v as i64)253 .map_err(|_| Error::invalid_value(Unexpected::Signed(v as i64), &self))254 }255 };256257 (nonzero $primitive:ident $ty:ident : $visit:ident) => {258 fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>259 where260 E: Error,261 {265 if $primitive::MIN as i64 <= v as i64 && v as i64 <= $primitive::MAX as i64 {266 if let Some(nonzero) = Self::Value::new(v as $primitive) {262 if let Ok(v) = $primitive::try_from(v as i64) {263 if let Some(nonzero) = Self::Value::new(v) {264 return Ok(nonzero);265 }266 }267 Err(Error::invalid_value(Unexpected::Signed(v as i64), &self))
22 unmodified lines
290 fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>291 where292 E: Error,293 {297 if 0 <= v && v as u64 <= Self::Value::MAX as u64 {298 Ok(v as Self::Value)299 } else {300 Err(Error::invalid_value(Unexpected::Signed(v as i64), &self))294 if 0 <= v {295 #[allow(irrefutable_let_patterns)]296 if let Ok(v) = Self::Value::try_from(v as u64) {297 return Ok(v as Self::Value);298 }299 }300 Err(Error::invalid_value(Unexpected::Signed(v as i64), &self))301 }302 };303304 (nonzero $primitive:ident $ty:ident : $visit:ident) => {305 fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>306 where307 E: Error,308 {309 if 0 < v {310 #[allow(irrefutable_let_patterns)]310 if 0 < v && v as u64 <= $primitive::MAX as u64 {311 if let Some(nonzero) = Self::Value::new(v as $primitive) {312 return Ok(nonzero);311 if let Ok(v) = $primitive::try_from(v as u64) {312 if let Some(nonzero) = Self::Value::new(v) {313 return Ok(nonzero);314 }315 }316 }317 Err(Error::invalid_value(Unexpected::Signed(v as i64), &self))318 }
21 unmodified lines
340 fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>341 where342 E: Error,343 {342 if v as u64 <= Self::Value::MAX as u64 {343 Ok(v as Self::Value)344 } else {345 Err(Error::invalid_value(Unexpected::Unsigned(v as u64), &self))346 }344 Self::Value::try_from(v as u64)345 .map_err(|_| Error::invalid_value(Unexpected::Unsigned(v as u64), &self))346 }347 };348349 (nonzero $primitive:ident $ty:ident : $visit:ident) => {350 fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>351 where352 E: Error,353 {355 if v as u64 <= $primitive::MAX as u64 {356 if let Some(nonzero) = Self::Value::new(v as $primitive) {354 if let Ok(v) = $primitive::try_from(v as u64) {355 if let Some(nonzero) = Self::Value::new(v) {356 return Ok(nonzero);357 }358 }359 Err(Error::invalid_value(Unexpected::Unsigned(v as u64), &self))
4 unmodified lines
364 fn $visit<E>(self, v: $ty) -> Result<Self::Value, E>365 where366 E: Error,367 {369 if v as u64 <= $primitive::MAX as u64 {368 if let Ok(v) = $primitive::try_from(v as u64) {369 Ok(Saturating(v as $primitive))370 } else {371 Ok(Saturating($primitive::MAX))372 }
2797 unmodified lines
modified:serde/src/de/size_hint.rs+1 added
1#[cfg(any(feature = "std", feature = "alloc"))]2use crate::lib::*;34pub fn from_bounds<I>(iter: &I) -> Option<usize>5where
25 unmodified lines
modified:serde/src/lib.rs-2 removed
173 unmodified lines
174 pub use std::*;175 }176177 pub use self::core::{f32, f64};178 pub use self::core::{i16, i32, i64, i8, isize};178 pub use self::core::{iter, num, ptr, str};180 pub use self::core::{u16, u32, u64, u8, usize};179180 #[cfg(any(feature = "std", feature = "alloc"))]181 pub use self::core::{cmp, mem, slice};182
165 unmodified lines