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

Commit 1b97006

Browse files
committed
Fixes & clippy.
1 parent 916cbcc commit 1b97006

File tree

5 files changed

+58
-61
lines changed

5 files changed

+58
-61
lines changed

examples/ical_generator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extern crate ical;
22

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

66
#[cfg(all(feature = "ical", feature = "generator"))]
77
fn main() {

src/generator/event_builder.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use {ical_property,ical_param};
21
use parser::ical::component::IcalEvent;
32
use property::Property;
3+
use {ical_param, ical_property};
44

55
#[allow(dead_code)]
66
pub const ICAL_DATE_FORMAT: &str = "%Y%m%dT%H%M%S";
@@ -170,7 +170,6 @@ impl Finalizer {
170170
.push(ical_property!("RRULE", value.into()));
171171
Finalizer(self.0)
172172
}
173-
174173
}
175174

176175
#[allow(unused)]
@@ -193,23 +192,26 @@ mod should {
193192
//let e = start.format(ICAL_DATE_FORMAT).to_string();
194193
assert_eq!(
195194
e,
196-
"BEGIN:VEVENT\nUID:UID_@_test\nDTSTAMP;TZID=Europe/Berlin:20201201T120423\n\
197-
DTSTART;TZID=Europe/Berlin:20201206T170000\n\
198-
DURATION:PT2H45M0S\nEND:VEVENT\n"
195+
"BEGIN:VEVENT\r\n\
196+
UID:UID_@_test\r\n\
197+
DTSTAMP;TZID=Europe/Berlin:20201201T120423\r\n\
198+
DTSTART;TZID=Europe/Berlin:20201206T170000\r\n\
199+
DURATION:PT2H45M0S\r\n\
200+
END:VEVENT\r\n"
199201
);
200202
}
201203

202204
#[test]
203205
fn build_whole_day_event() {
204206
use generator::Emitter;
205-
let expect = "BEGIN:VEVENT\n\
206-
UID:20070423T123432Z-541111@example.com\n\
207-
DTSTAMP:20070423T123432Z\n\
208-
DTSTART;VALUE=DATE:20070628\n\
209-
DTEND;VALUE=DATE:20070709\n\
210-
SUMMARY:Festival International de Jazz de Montreal\n\
211-
TRANSP:TRANSPARENT\n\
212-
END:VEVENT\n\
207+
let expect = "BEGIN:VEVENT\r\n\
208+
UID:20070423T123432Z-541111@example.com\r\n\
209+
DTSTAMP:20070423T123432Z\r\n\
210+
DTSTART;VALUE=DATE:20070628\r\n\
211+
DTEND;VALUE=DATE:20070709\r\n\
212+
SUMMARY:Festival International de Jazz de Montreal\r\n\
213+
TRANSP:TRANSPARENT\r\n\
214+
END:VEVENT\r\n\
213215
";
214216
let event = IcalEventBuilder::tzid("America/Montreal")
215217
.uid("20070423T123432Z-541111@example.com")
@@ -229,16 +231,16 @@ mod should {
229231
#[test]
230232
fn build_frequent_ical_event() {
231233
use generator::Emitter;
232-
let expect = "BEGIN:VEVENT\n\
233-
UID:19970901T130000Z-123403@example.com\n\
234-
DTSTAMP:19970901T130000Z\n\
235-
DTSTART;VALUE=DATE:19971102\n\
236-
RRULE:FREQ=YEARLY\n\
237-
SUMMARY:Our Blissful Anniversary\n\
238-
TRANSP:TRANSPARENT\n\
239-
CLASS:CONFIDENTIAL\n\
240-
CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION\n\
241-
END:VEVENT\n\
234+
let expect = "BEGIN:VEVENT\r\n\
235+
UID:19970901T130000Z-123403@example.com\r\n\
236+
DTSTAMP:19970901T130000Z\r\n\
237+
DTSTART;VALUE=DATE:19971102\r\n\
238+
RRULE:FREQ=YEARLY\r\n\
239+
SUMMARY:Our Blissful Anniversary\r\n\
240+
TRANSP:TRANSPARENT\r\n\
241+
CLASS:CONFIDENTIAL\r\n\
242+
CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION\r\n\
243+
END:VEVENT\r\n\
242244
";
243245
let event = IcalEventBuilder::tzid("America/Montreal")
244246
.uid("19970901T130000Z-123403@example.com")

src/generator/ical.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) fn split_line<T: Into<String>>(str: T) -> String {
2323
let mut x = 75;
2424
while x < str.len() {
2525
str.insert_str(x, "\r\n ");
26-
x += 76;
26+
x += 77;
2727
}
2828
str
2929
}
@@ -78,11 +78,11 @@ mod should {
7878

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

8888
#[test]

src/generator/vcard_builder.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,24 @@ mod should {
173173
#[test]
174174
fn build_vcards_wikipedia_example() {
175175
use generator::Emitter;
176-
let expect = "BEGIN:VCARD\n\
177-
VERSION:4.0\n\
178-
N:Gump;Forrest;;Mr.;\n\
179-
FN:Forrest Gump\n\
180-
ORG:Bubba Gump Shrimp Co.\n\
181-
TITLE:Shrimp Man\n\
182-
PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif\n\
183-
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212\n\
184-
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212\n\
185-
ADR;TYPE=WORK;PREF=1;LABEL=\"100 Waters Edge\\nBaytown\\, LA 30314\\nUnited Sta\n \
186-
tes of America\":;;100 Waters Edge;Baytown;LA;30314;United States of Americ\n \
187-
a\n\
188-
ADR;TYPE=HOME;LABEL=\"42 Plantation St.\\nBaytown\\, LA 30314\\nUnited States o\n f \
189-
America\":;;42 Plantation St.;Baytown;LA;30314;United States of America\n\
190-
EMAIL:forrestgump@example.com\n\
191-
REV:20080424T195243Z\n\
192-
x-qq:21588891\n\
193-
END:VCARD\n\
176+
let expect = "BEGIN:VCARD\r\n\
177+
VERSION:4.0\r\n\
178+
N:Gump;Forrest;;Mr.;\r\n\
179+
FN:Forrest Gump\r\n\
180+
ORG:Bubba Gump Shrimp Co.\r\n\
181+
TITLE:Shrimp Man\r\n\
182+
PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif\r\n\
183+
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212\r\n\
184+
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212\r\n\
185+
ADR;TYPE=WORK;PREF=1;LABEL=\"100 Waters Edge\\nBaytown\\, LA 30314\\nUnited Sta\r\n \
186+
tes of America\":;;100 Waters Edge;Baytown;LA;30314;United States of Americ\r\n \
187+
a\r\n\
188+
ADR;TYPE=HOME;LABEL=\"42 Plantation St.\\nBaytown\\, LA 30314\\nUnited States o\r\n f \
189+
America\":;;42 Plantation St.;Baytown;LA;30314;United States of America\r\n\
190+
EMAIL:forrestgump@example.com\r\n\
191+
REV:20080424T195243Z\r\n\
192+
x-qq:21588891\r\n\
193+
END:VCARD\r\n\
194194
";
195195

196196
let vcard = IcalVcardBuilder::version("4.0")
@@ -245,12 +245,12 @@ mod should {
245245
#[test]
246246
fn build_vcard_with_fn_generated() {
247247
use generator::Emitter;
248-
let expect = "BEGIN:VCARD\n\
249-
VERSION:4.0\n\
250-
N:Marx;Adolph;Arthur;Mr.;\n\
251-
FN:Mr. Adolph Arthur Marx\n\
252-
NICKNAME:Harpo Marx\n\
253-
END:VCARD\n\
248+
let expect = "BEGIN:VCARD\r\n\
249+
VERSION:4.0\r\n\
250+
N:Marx;Adolph;Arthur;Mr.;\r\n\
251+
FN:Mr. Adolph Arthur Marx\r\n\
252+
NICKNAME:Harpo Marx\r\n\
253+
END:VCARD\r\n\
254254
";
255255
let vcard = IcalVcardBuilder::version("4.0")
256256
.names(

src/parser/ical/component.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,14 @@ impl Component for IcalTimeZone {
313313
}
314314
}
315315

316-
#[derive(Debug, Clone)]
316+
#[derive(Debug, Clone, Default)]
317317
#[cfg_attr(feature = "serde-derive", derive(serde::Serialize, serde::Deserialize))]
318318
pub enum IcalTimeZoneTransitionType {
319+
#[default]
319320
STANDARD,
320321
DAYLIGHT,
321322
}
322323

323-
impl Default for IcalTimeZoneTransitionType {
324-
fn default() -> Self {
325-
IcalTimeZoneTransitionType::STANDARD
326-
}
327-
}
328-
329324
#[derive(Debug, Clone, Default)]
330325
#[cfg_attr(feature = "serde-derive", derive(serde::Serialize, serde::Deserialize))]
331326
pub struct IcalTimeZoneTransition {

0 commit comments

Comments
 (0)