Skip to content

Commit

Permalink
Merge pull request #95 from hoodie/feature/clippy178
Browse files Browse the repository at this point in the history
refactor: fix new lints
  • Loading branch information
hoodie authored Apr 29, 2024
2 parents 2834f73 + 761a1e7 commit e527601
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ chrono-tz = {version = "0.8", optional = true }

[dependencies.chrono]
version = "0.4"
default_features = false
default-features = false
features = ["clock", "std", "wasmbind"]

[dependencies.nom]
Expand Down
1 change: 0 additions & 1 deletion examples/full_circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use std::str::FromStr;

use chrono::*;
use icalendar::parser;
use icalendar::*;

fn main() {
Expand Down
6 changes: 3 additions & 3 deletions src/calendar.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use chrono::Duration;
use std::{fmt, iter::FromIterator, mem, ops::Deref};
use std::{fmt, mem, ops::Deref};

use crate::{components::*, Parameter, Property};

Expand Down Expand Up @@ -232,7 +232,7 @@ impl fmt::Display for Calendar {
}

impl TryInto<String> for &Calendar {
type Error = std::fmt::Error;
type Error = fmt::Error;
fn try_into(self) -> Result<String, Self::Error> {
let mut out_string = String::new();
self.fmt_write(&mut out_string)?;
Expand Down Expand Up @@ -279,7 +279,7 @@ impl<C: Into<CalendarComponent>> FromIterator<C> for Calendar {
}
#[test]
fn from_adds_default_properties() {
let todo = crate::Todo::default();
let todo = Todo::default();
let cal = Calendar::from([todo]);
assert!(cal.property_value("VERSION").is_some());
assert!(cal.property_value("CALSCALE").is_some());
Expand Down
4 changes: 2 additions & 2 deletions src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub trait Component {
}

/// Serializes this component into [`rfc5545`](http://tools.ietf.org/html/rfc5545) again
fn try_into_string(&self) -> Result<String, std::fmt::Error> {
fn try_into_string(&self) -> Result<String, fmt::Error> {
let mut out_string = String::new();
self.fmt_write(&mut out_string)?;
Ok(out_string)
Expand Down Expand Up @@ -185,7 +185,7 @@ pub trait Component {
///
/// Ranges from 0 to 10, larger values will be truncated
fn priority(&mut self, priority: u32) -> &mut Self {
let priority = ::std::cmp::min(priority, 10);
let priority = std::cmp::min(priority, 10);
self.add_property("PRIORITY", &priority.to_string())
}

Expand Down
17 changes: 8 additions & 9 deletions src/components/alarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn test_email() {

pub mod properties {

use crate::components::{alarm::properties::Parameter, date_time::parse_duration};
use crate::components::date_time::parse_duration;

use super::*;

Expand Down Expand Up @@ -316,14 +316,13 @@ pub mod properties {
}
}

impl ToString for Action {
/// convert the ACTION into its serialized representation
fn to_string(&self) -> String {
impl fmt::Display for Action {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Action::Audio => "AUDIO".into(),
Action::Email => "EMAIL".into(),
Action::Display => "DISPLAY".into(),
Action::Other(other) => other.clone(),
Action::Audio => write!(f, "AUDIO"),
Action::Email => write!(f, "EMAIL"),
Action::Display => write!(f, "DISPLAY"),
Action::Other(other) => write!(f, "{}", other),
}
}
}
Expand Down Expand Up @@ -411,7 +410,7 @@ pub mod properties {
pub enum Trigger {
/// Duration in relation to either Start or End of the event
Duration(Duration, Option<Related>),
/// Absolute DateTime of the Trigger
/// Absolute `DateTime` of the Trigger
DateTime(CalendarDateTime),
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/date_time.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(dead_code, unused)]
use std::str::FromStr;

use chrono::{Date, DateTime, Duration, NaiveDate, NaiveDateTime, Offset, TimeZone as _, Utc};
use chrono::{DateTime, Duration, NaiveDate, NaiveDateTime, Offset, TimeZone as _, Utc};

use crate::{Property, ValueType};

Expand Down Expand Up @@ -299,8 +299,8 @@ impl From<DateTime<Utc>> for DatePerhapsTime {
// }

#[allow(deprecated)]
impl From<Date<Utc>> for DatePerhapsTime {
fn from(dt: Date<Utc>) -> Self {
impl From<chrono::Date<Utc>> for DatePerhapsTime {
fn from(dt: chrono::Date<Utc>) -> Self {
Self::Date(dt.naive_utc())
}
}
Expand Down
1 change: 0 additions & 1 deletion src/components/todo.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use chrono::*;

use super::date_time::parse_utc_date_time;
use super::*;

/// VTODO [(RFC 5545, Section 3.6.2 )](https://tools.ietf.org/html/rfc5545#section-3.6.2)
Expand Down
2 changes: 1 addition & 1 deletion src/parser/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl FromStr for CalendarComponent {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let from_parsed = crate::CalendarComponent::from(read_component(&unfold(s))?);
let from_parsed = CalendarComponent::from(read_component(&unfold(s))?);
Ok(from_parsed)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/parser/parsed_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ impl From<String> for ParseString<'static> {
}
}

impl ToString for ParseString<'_> {
fn to_string(&self) -> String {
self.to_owned().into()
impl std::fmt::Display for ParseString<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl FromStr for crate::Property {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(crate::parser::Property::try_from(s)?.into())
Ok(Property::try_from(s)?.into())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Property {
}

impl TryInto<String> for Property {
type Error = std::fmt::Error;
type Error = fmt::Error;

fn try_into(self) -> Result<String, Self::Error> {
let mut out_string = String::new();
Expand Down
1 change: 0 additions & 1 deletion tests/try_into_string.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use chrono::*;
use icalendar::*;
use std::convert::TryInto;

#[test]
fn try_into_string() -> Result<(), Box<dyn std::error::Error>> {
Expand Down

0 comments on commit e527601

Please sign in to comment.