mirror of
https://github.com/chronotope/chrono.git
synced 2025-10-02 15:26:12 +00:00
Apply clippy suggestions
This commit is contained in:
parent
f6b575ceee
commit
db8bde3acf
@ -22,7 +22,7 @@ use crate::{Datelike, Timelike};
|
||||
///
|
||||
/// - `to_*` methods try to make a concrete date and time value out of set fields.
|
||||
/// It fully checks any remaining out-of-range conditions and inconsistent/impossible fields.
|
||||
#[derive(Clone, PartialEq, Debug, Default)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Default)]
|
||||
pub struct Parsed {
|
||||
/// Year.
|
||||
///
|
||||
|
@ -201,7 +201,7 @@ impl Months {
|
||||
}
|
||||
|
||||
/// An error resulting from reading `<Month>` value with `FromStr`.
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct ParseMonthError {
|
||||
pub(crate) _dummy: (),
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ fn test_date_bounds() {
|
||||
impl NaiveDate {
|
||||
/// Makes a new `NaiveDate` from year and packed ordinal-flags, with a verification.
|
||||
fn from_of(year: i32, of: Of) -> Option<NaiveDate> {
|
||||
if year >= MIN_YEAR && year <= MAX_YEAR && of.valid() {
|
||||
if (MIN_YEAR..=MAX_YEAR).contains(&year) && of.valid() {
|
||||
let Of(of) = of;
|
||||
Some(NaiveDate { ymdf: (year << 13) | (of as DateImpl) })
|
||||
} else {
|
||||
|
@ -536,7 +536,6 @@ impl NaiveTime {
|
||||
/// assert_eq!(from_hms(3, 4, 5).overflowing_add_signed(Duration::hours(-7)),
|
||||
/// (from_hms(20, 4, 5), -86_400));
|
||||
/// ```
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))]
|
||||
pub fn overflowing_add_signed(&self, mut rhs: OldDuration) -> (NaiveTime, i64) {
|
||||
let mut secs = self.secs;
|
||||
let mut frac = self.frac;
|
||||
@ -585,7 +584,7 @@ impl NaiveTime {
|
||||
frac -= 1_000_000_000;
|
||||
secs += 1;
|
||||
}
|
||||
debug_assert!(-86_400 <= secs && secs < 2 * 86_400);
|
||||
debug_assert!((-86_400..2 * 86_400).contains(&secs));
|
||||
debug_assert!((0..1_000_000_000).contains(&frac));
|
||||
|
||||
if secs < 0 {
|
||||
|
@ -229,7 +229,7 @@ impl<'a> Cursor<'a> {
|
||||
}
|
||||
|
||||
pub(crate) fn peek(&self) -> Option<&u8> {
|
||||
self.remaining().get(0)
|
||||
self.remaining().first()
|
||||
}
|
||||
|
||||
/// Returns remaining data
|
||||
|
@ -399,7 +399,7 @@ fn parse_rule_time(cursor: &mut Cursor) -> Result<i32, Error> {
|
||||
fn parse_rule_time_extended(cursor: &mut Cursor) -> Result<i32, Error> {
|
||||
let (sign, hour, minute, second) = parse_signed_hhmmss(cursor)?;
|
||||
|
||||
if hour < -167 || hour > 167 {
|
||||
if !(-167..=167).contains(&hour) {
|
||||
return Err(Error::InvalidTzString("invalid day time hour"));
|
||||
}
|
||||
if !(0..=59).contains(&minute) {
|
||||
|
@ -186,7 +186,7 @@ impl num_traits::FromPrimitive for Weekday {
|
||||
}
|
||||
|
||||
/// An error resulting from reading `Weekday` value with `FromStr`.
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct ParseWeekdayError {
|
||||
pub(crate) _dummy: (),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user