From 8a29f30fb2a949c03b318c4f7699136a8001be37 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 13 Feb 2022 12:17:00 +0100 Subject: Synchronize deck only if necessary Look at the modification time of the deck, and synchronize if it has been modified after the last deck read. --- src/deck.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/deck.rs') diff --git a/src/deck.rs b/src/deck.rs index 3524c96..e0f9fab 100644 --- a/src/deck.rs +++ b/src/deck.rs @@ -23,7 +23,7 @@ impl std::error::Error for ParseError { } } -pub fn read(deck: &String) -> Result> { +pub fn read(deck: &str) -> Result> { let file = File::open(deck)?; let reader = BufReader::new(file); let mut entries: Vec = Vec::new(); @@ -69,7 +69,9 @@ pub fn read(deck: &String) -> Result> { } pub fn pp_from_path(path: &String) -> Option { - Some(capitalize(Path::new(&path).with_extension("").file_name()?.to_str()?)) + Some(capitalize( + Path::new(&path).with_extension("").file_name()?.to_str()?, + )) } fn capitalize(s: &str) -> String { -- cgit v1.2.3