aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 43cdc5b..af10ccb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -55,11 +55,15 @@ fn print_event(event: &ical::parser::ical::component::IcalEvent) {
summary);
}
-fn main() {
- let buf = BufReader::new(File::open("test.ics").unwrap());
- let calendars: Vec<_> = ical::IcalParser::new(buf)
+fn read_icalendar_from_file(filename: &str) -> std::io::Result<Vec<ical::parser::ical::component::IcalCalendar>> {
+ let buf = BufReader::new(File::open(filename)?);
+ Ok(ical::IcalParser::new(buf)
.filter_map(|c| c.ok())
- .collect();
+ .collect())
+}
+
+fn main() {
+ let calendars = read_icalendar_from_file("test.ics").unwrap();
println!("Found {} calendard in file...", calendars.len());
for c in calendars {