Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edition 2018 idioms #93

Merged
merged 2 commits into from
Sep 8, 2021
Merged
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
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
A cron expression parser. Works with stable Rust v1.28.0.

```rust
extern crate cron;
extern crate chrono;

use cron::Schedule;
use chrono::Utc;
use std::str::FromStr;
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum ErrorKind {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.kind {
ErrorKind::Expression(ref expr) => write!(f, "Invalid expression: {}", expr),
}
Expand Down
9 changes: 1 addition & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![deny(rust_2018_idioms)]

//! A cron expression parser and schedule explorer
//! # Example
//! ```
//! extern crate chrono;
//! extern crate cron;
//!
//! use cron::Schedule;
//! use chrono::Utc;
//! use std::str::FromStr;
Expand Down Expand Up @@ -36,9 +32,6 @@
//! */
//! ```

#[cfg(test)]
extern crate chrono_tz;

pub mod error;
mod schedule;
mod time_unit;
Expand Down
6 changes: 3 additions & 3 deletions src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ impl Schedule {

/// Provides an iterator which will return each DateTime that matches the schedule starting with
/// the current time if applicable.
pub fn upcoming<Z>(&self, timezone: Z) -> ScheduleIterator<Z>
pub fn upcoming<Z>(&self, timezone: Z) -> ScheduleIterator<'_, Z>
where
Z: TimeZone,
{
self.after(&timezone.from_utc_datetime(&Utc::now().naive_utc()))
}

/// Like the `upcoming` method, but allows you to specify a start time other than the present.
pub fn after<Z>(&self, after: &DateTime<Z>) -> ScheduleIterator<Z>
pub fn after<Z>(&self, after: &DateTime<Z>) -> ScheduleIterator<'_, Z>
where
Z: TimeZone,
{
Expand Down Expand Up @@ -295,7 +295,7 @@ impl Schedule {
}

impl Display for Schedule {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that rustfix prefers to make these elisions explicit since that makes things more verbose. If you happen to have a link explaining the motivation, I'd be curious to learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write!(f, "{}", self.source)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/time_unit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub trait TimeUnitSpec {
/// assert_eq!(Some(8), summer.next());
/// assert_eq!(None, summer.next());
/// ```
fn iter(&self) -> OrdinalIter;
fn iter(&self) -> OrdinalIter<'_>;

/// Provides an iterator which will return each included ordinal within the specified range.
/// # Example
Expand All @@ -140,7 +140,7 @@ pub trait TimeUnitSpec {
/// assert_eq!(Some(15), mid_month_paydays.next());
/// assert_eq!(None, mid_month_paydays.next());
/// ```
fn range<R>(&self, range: R) -> OrdinalRangeIter
fn range<R>(&self, range: R) -> OrdinalRangeIter<'_>
where
R: RangeBounds<Ordinal>;

Expand Down Expand Up @@ -179,7 +179,7 @@ where
fn includes(&self, ordinal: Ordinal) -> bool {
self.ordinals().contains(&ordinal)
}
fn iter(&self) -> OrdinalIter {
fn iter(&self) -> OrdinalIter<'_> {
OrdinalIter {
set_iter: TimeUnitField::ordinals(self).iter(),
}
Expand Down
4 changes: 0 additions & 4 deletions tests/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
extern crate chrono;
extern crate chrono_tz;
extern crate cron;

#[cfg(test)]
mod tests {
use chrono::*;
Expand Down