Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.51.0
1.63.0
2 changes: 1 addition & 1 deletion saffron/src/describe/english.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl English {
),
})
}
fn hour<'a>(&'a self, h: OrsExpr<Hour>) -> impl Display + 'a {
fn hour(&self, h: OrsExpr<Hour>) -> impl Display + '_ {
display(move |f| match h {
OrsExpr::One(hour) => write!(
f,
Expand Down
14 changes: 7 additions & 7 deletions saffron/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,14 +1078,14 @@ impl Cron {
}

let front = match bounds.start_bound() {
Bound::Unbounded => Some(chrono::MIN_DATETIME),
Bound::Unbounded => Some(DateTime::<Utc>::MIN_UTC),
Bound::Included(start) => Some(*start),
Bound::Excluded(start) => next_minute(*start),
}
.map(minute_floor);

let back = match bounds.end_bound() {
Bound::Unbounded => Some(chrono::MAX_DATETIME),
Bound::Unbounded => Some(DateTime::<Utc>::MAX_UTC),
Bound::Included(end) => Some(*end),
Bound::Excluded(end) => previous_minute(*end),
}
Expand Down Expand Up @@ -1113,7 +1113,7 @@ impl Cron {
pub fn next_from(&self, start: DateTime<Utc>) -> Option<DateTime<Utc>> {
let start = minute_floor(start);
if self.any() {
self.find_next(start, chrono::MAX_DATETIME)
self.find_next(start, DateTime::<Utc>::MAX_UTC)
} else {
None
}
Expand All @@ -1134,7 +1134,7 @@ impl Cron {
pub fn next_after(&self, start: DateTime<Utc>) -> Option<DateTime<Utc>> {
let start = next_minute(minute_floor(start))?;
if self.any() {
self.find_next(start, chrono::MAX_DATETIME)
self.find_next(start, DateTime::<Utc>::MAX_UTC)
} else {
None
}
Expand Down Expand Up @@ -1935,7 +1935,7 @@ mod tests {

let results = cron.iter((start, end)).collect::<Vec<_>>();
let times = times
.into_iter()
.iter()
.map(|&time| {
Utc.datetime_from_str(time, FORMAT)
.expect("Failed to parse expected date")
Expand Down Expand Up @@ -1994,7 +1994,7 @@ mod tests {
assert(
"* * * * *",
(
Bound::Excluded(&chrono::MAX_DATETIME.format(FORMAT).to_string().as_str()),
Bound::Excluded(&DateTime::<Utc>::MAX_UTC.format(FORMAT).to_string().as_str()),
Bound::Unbounded,
),
&[],
Expand All @@ -2007,7 +2007,7 @@ mod tests {
"* * * * *",
(
Bound::Unbounded,
Bound::Excluded(chrono::MIN_DATETIME.format(FORMAT).to_string().as_str()),
Bound::Excluded(DateTime::<Utc>::MIN_UTC.format(FORMAT).to_string().as_str()),
),
&[],
)
Expand Down
23 changes: 9 additions & 14 deletions saffron/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl TryFrom<u8> for DayOfMonth {

#[inline]
fn try_from(value: u8) -> Result<Self, Self::Error> {
if value >= Self::MIN && value <= Self::MAX {
if (Self::MIN..=Self::MAX).contains(&value) {
Ok(Self(value))
} else {
Err(ValueOutOfRangeError)
Expand Down Expand Up @@ -201,7 +201,7 @@ impl TryFrom<u8> for DayOfMonthOffset {

#[inline]
fn try_from(value: u8) -> Result<Self, Self::Error> {
if value >= Self::MIN && value <= Self::MAX {
if (Self::MIN..=Self::MAX).contains(&value) {
Ok(Self(value))
} else {
Err(ValueOutOfRangeError)
Expand Down Expand Up @@ -281,7 +281,7 @@ impl TryFrom<u8> for Month {

#[inline]
fn try_from(value: u8) -> Result<Self, Self::Error> {
if value >= Self::MIN && value <= Self::MAX {
if (Self::MIN..=Self::MAX).contains(&value) {
Ok(Self(value))
} else {
Err(ValueOutOfRangeError)
Expand Down Expand Up @@ -321,7 +321,7 @@ impl TryFrom<u8> for NthDay {

#[inline]
fn try_from(value: u8) -> Result<Self, Self::Error> {
if value >= Self::MIN && value <= Self::MAX {
if (Self::MIN..=Self::MAX).contains(&value) {
Ok(Self(value))
} else {
Err(ValueOutOfRangeError)
Expand Down Expand Up @@ -717,11 +717,7 @@ where
}

/// Consumes a set of trailing ORS expressions
fn tail_ors_exprs<'a, E, F>(
mut input: &'a str,
f: F,
mut exprs: Exprs<E>,
) -> IResult<&'a str, Exprs<E>>
fn tail_ors_exprs<E, F>(mut input: &str, f: F, mut exprs: Exprs<E>) -> IResult<&str, Exprs<E>>
where
E: ExprValue + TryFrom<u8, Error = ValueOutOfRangeError> + Ord + Copy,
F: Fn(&str) -> IResult<&str, E>,
Expand All @@ -747,15 +743,14 @@ where
F: Fn(&str) -> IResult<&str, E>,
{
move |mut input: &str| {
let expressions: Exprs<E>;
// Attempt to read a `*`. If that succeeds,
// try to read a `/` for a step expr.
// If this isn't a step expr, return Expr::All,
// If it's not a `*`, initialize the expressions
// list with an ors_expr.
let star = opt(char('*'))(input)?;
input = star.0;
if star.1.is_some() {
let expressions = if star.1.is_some() {
let slash = opt(char('/'))(input)?;
input = slash.0;
// If there is no slash after this, just return All and expect the next
Expand All @@ -765,16 +760,16 @@ where
}
let step = step_digit::<E>()(input)?;
input = step.0;
expressions = Exprs::new(OrsExpr::Step {
Exprs::new(OrsExpr::Step {
start: ExprValue::min(),
end: ExprValue::max(),
step: step.1,
})
} else {
let expr = ors_expr::<E, _>(&f)(input)?;
input = expr.0;
expressions = Exprs::new(expr.1)
}
Exprs::new(expr.1)
};

let (input, exprs) = tail_ors_exprs(input, &f, expressions)?;

Expand Down