aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-12-18 13:05:32 +0100
committerHarald Eilertsen <haraldei@anduin.net>2018-12-18 13:05:32 +0100
commit20a3b4e71b3706e1ee15a8f3d3d9640fd3a8b460 (patch)
tree6789765d90b2be1866266409ef28e217d8a2ce7d /src
parent0e8a887e09b4065e6ed7f1c5ab547e3b17a96742 (diff)
downloadicaltool-20a3b4e71b3706e1ee15a8f3d3d9640fd3a8b460.tar.gz
icaltool-20a3b4e71b3706e1ee15a8f3d3d9640fd3a8b460.tar.bz2
icaltool-20a3b4e71b3706e1ee15a8f3d3d9640fd3a8b460.zip
Move reading of calendar file to function.
Diffstat (limited to 'src')
-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 {