From f0648bcc4e7a6b7ce3f59013f25413a667dc507a Mon Sep 17 00:00:00 2001 From: Julian T Date: Tue, 27 Jul 2021 17:46:28 +0200 Subject: Sort by timestamps and switch to thiserror crate --- src/main.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index b647cdc..40b1faf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,20 +2,26 @@ mod context; mod picture; mod piece; +use std::error::Error; + use context::Context; use picture::Picture; use piece::Piece; -fn main() { +fn main() -> Result<(), Box> { println!("Hello, world!"); - let ctx = Context::new_with_args().unwrap(); + let ctx = Context::new_with_args()?; - let pieces = ctx.get_image_files().unwrap().iter() - .map(|file| Picture::new_from_file(&file).unwrap()) - .map(|pic| Piece::new(&ctx, pic).unwrap()) - .collect::>(); + let mut pieces = ctx.get_image_files()?.iter() + .map(|file| -> Result> { + let pic = Picture::new_from_file(&file)?; + Ok(Piece::new(&ctx, pic)?) + }).collect::, Box>>()?; + pieces.sort(); + pieces.reverse(); - piece::create_index(&ctx, &pieces[..]).unwrap(); + piece::create_index(&ctx, &pieces[..])?; + Ok(()) } -- cgit v1.2.3