Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
Fixes & clippy.
Browse files Browse the repository at this point in the history
  • Loading branch information
westy92 authored and Peltoche committed Jan 17, 2024
1 parent 821bd46 commit 79b0e65
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 59 deletions.
4 changes: 2 additions & 2 deletions examples/ical_generator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate ical;

use std::fs::File;
use std::io::BufReader;
#[cfg(all(feature = "ical", feature = "generator"))]
use std::{fs::File, io::BufReader};

#[cfg(all(feature = "ical", feature = "generator"))]
fn main() {
Expand Down
45 changes: 24 additions & 21 deletions src/generator/event_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,26 @@ mod should {
//let e = start.format(ICAL_DATE_FORMAT).to_string();
assert_eq!(
e,
"BEGIN:VEVENT\nUID:UID_@_test\nDTSTAMP;TZID=Europe/Berlin:20201201T120423\n\
DTSTART;TZID=Europe/Berlin:20201206T170000\n\
DURATION:PT2H45M0S\nEND:VEVENT\n"
"BEGIN:VEVENT\r\n\
UID:UID_@_test\r\n\
DTSTAMP;TZID=Europe/Berlin:20201201T120423\r\n\
DTSTART;TZID=Europe/Berlin:20201206T170000\r\n\
DURATION:PT2H45M0S\r\n\
END:VEVENT\r\n"
);
}

#[test]
fn build_whole_day_event() {
use generator::Emitter;
let expect = "BEGIN:VEVENT\n\
UID:[email protected]\n\
DTSTAMP:20070423T123432Z\n\
DTSTART;VALUE=DATE:20070628\n\
DTEND;VALUE=DATE:20070709\n\
SUMMARY:Festival International de Jazz de Montreal\n\
TRANSP:TRANSPARENT\n\
END:VEVENT\n\
let expect = "BEGIN:VEVENT\r\n\
UID:[email protected]\r\n\
DTSTAMP:20070423T123432Z\r\n\
DTSTART;VALUE=DATE:20070628\r\n\
DTEND;VALUE=DATE:20070709\r\n\
SUMMARY:Festival International de Jazz de Montreal\r\n\
TRANSP:TRANSPARENT\r\n\
END:VEVENT\r\n\
";
let event = IcalEventBuilder::tzid("America/Montreal")
.uid("[email protected]")
Expand All @@ -228,16 +231,16 @@ mod should {
#[test]
fn build_frequent_ical_event() {
use generator::Emitter;
let expect = "BEGIN:VEVENT\n\
UID:[email protected]\n\
DTSTAMP:19970901T130000Z\n\
DTSTART;VALUE=DATE:19971102\n\
RRULE:FREQ=YEARLY\n\
SUMMARY:Our Blissful Anniversary\n\
TRANSP:TRANSPARENT\n\
CLASS:CONFIDENTIAL\n\
CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION\n\
END:VEVENT\n\
let expect = "BEGIN:VEVENT\r\n\
UID:[email protected]\r\n\
DTSTAMP:19970901T130000Z\r\n\
DTSTART;VALUE=DATE:19971102\r\n\
RRULE:FREQ=YEARLY\r\n\
SUMMARY:Our Blissful Anniversary\r\n\
TRANSP:TRANSPARENT\r\n\
CLASS:CONFIDENTIAL\r\n\
CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION\r\n\
END:VEVENT\r\n\
";
let event = IcalEventBuilder::tzid("America/Montreal")
.uid("[email protected]")
Expand Down
10 changes: 5 additions & 5 deletions src/generator/ical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) fn split_line<T: Into<String>>(str: T) -> String {
let mut x = 75;
while x < str.len() {
str.insert_str(x, "\r\n ");
x += 76;
x += 77;
}
str
}
Expand Down Expand Up @@ -78,11 +78,11 @@ mod should {

#[test]
fn split_long_line() {
let text = "The ability to return a type that is only specified by the trait it impleme\n \
nts is especially useful in the context closures and iterators, which we c\n \
over in Chapter 13. Closures and iterators create types that only the comp\n \
let text = "The ability to return a type that is only specified by the trait it impleme\r\n \
nts is especially useful in the context closures and iterators, which we c\r\n \
over in Chapter 13. Closures and iterators create types that only the comp\r\n \
iler knows or types that are very long to specify.";
assert_eq!(text, split_line(text.replace("\n ", "")));
assert_eq!(text, split_line(text.replace("\r\n ", "")));
}

#[test]
Expand Down
48 changes: 24 additions & 24 deletions src/generator/vcard_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,24 @@ mod should {
#[test]
fn build_vcards_wikipedia_example() {
use generator::Emitter;
let expect = "BEGIN:VCARD\n\
VERSION:4.0\n\
N:Gump;Forrest;;Mr.;\n\
FN:Forrest Gump\n\
ORG:Bubba Gump Shrimp Co.\n\
TITLE:Shrimp Man\n\
PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif\n\
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212\n\
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212\n\
ADR;TYPE=WORK;PREF=1;LABEL=\"100 Waters Edge\\nBaytown\\, LA 30314\\nUnited Sta\n \
tes of America\":;;100 Waters Edge;Baytown;LA;30314;United States of Americ\n \
a\n\
ADR;TYPE=HOME;LABEL=\"42 Plantation St.\\nBaytown\\, LA 30314\\nUnited States o\n f \
America\":;;42 Plantation St.;Baytown;LA;30314;United States of America\n\
EMAIL:[email protected]\n\
REV:20080424T195243Z\n\
x-qq:21588891\n\
END:VCARD\n\
let expect = "BEGIN:VCARD\r\n\
VERSION:4.0\r\n\
N:Gump;Forrest;;Mr.;\r\n\
FN:Forrest Gump\r\n\
ORG:Bubba Gump Shrimp Co.\r\n\
TITLE:Shrimp Man\r\n\
PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif\r\n\
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212\r\n\
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212\r\n\
ADR;TYPE=WORK;PREF=1;LABEL=\"100 Waters Edge\\nBaytown\\, LA 30314\\nUnited Sta\r\n \
tes of America\":;;100 Waters Edge;Baytown;LA;30314;United States of Americ\r\n \
a\r\n\
ADR;TYPE=HOME;LABEL=\"42 Plantation St.\\nBaytown\\, LA 30314\\nUnited States o\r\n f \
America\":;;42 Plantation St.;Baytown;LA;30314;United States of America\r\n\
EMAIL:[email protected]\r\n\
REV:20080424T195243Z\r\n\
x-qq:21588891\r\n\
END:VCARD\r\n\
";

let vcard = IcalVcardBuilder::version("4.0")
Expand Down Expand Up @@ -245,12 +245,12 @@ mod should {
#[test]
fn build_vcard_with_fn_generated() {
use generator::Emitter;
let expect = "BEGIN:VCARD\n\
VERSION:4.0\n\
N:Marx;Adolph;Arthur;Mr.;\n\
FN:Mr. Adolph Arthur Marx\n\
NICKNAME:Harpo Marx\n\
END:VCARD\n\
let expect = "BEGIN:VCARD\r\n\
VERSION:4.0\r\n\
N:Marx;Adolph;Arthur;Mr.;\r\n\
FN:Mr. Adolph Arthur Marx\r\n\
NICKNAME:Harpo Marx\r\n\
END:VCARD\r\n\
";
let vcard = IcalVcardBuilder::version("4.0")
.names(
Expand Down
9 changes: 2 additions & 7 deletions src/parser/ical/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,19 +313,14 @@ impl Component for IcalTimeZone {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde-derive", derive(serde::Serialize, serde::Deserialize))]
pub enum IcalTimeZoneTransitionType {
#[default]
STANDARD,
DAYLIGHT,
}

impl Default for IcalTimeZoneTransitionType {
fn default() -> Self {
IcalTimeZoneTransitionType::STANDARD
}
}

#[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde-derive", derive(serde::Serialize, serde::Deserialize))]
pub struct IcalTimeZoneTransition {
Expand Down

0 comments on commit 79b0e65

Please sign in to comment.