From 2f3a52b2ab0821492866342bfce3089c9e40dea6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Apr 2016 15:48:59 +0200 Subject: [PATCH] Add IsInDiary trait --- libimagdiary/src/is_in_diary.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 libimagdiary/src/is_in_diary.rs diff --git a/libimagdiary/src/is_in_diary.rs b/libimagdiary/src/is_in_diary.rs new file mode 100644 index 00000000..0d0cfccb --- /dev/null +++ b/libimagdiary/src/is_in_diary.rs @@ -0,0 +1,26 @@ +use std::path::PathBuf; + +use libimagstore::store::Entry; + +pub trait IsInDiary { + + fn is_in_diary(&self, name: &str) -> bool; + +} + +impl IsInDiary for Entry { + + fn is_in_diary(&self, name: &str) -> bool { + self.get_location().is_in_diary(name) + } + +} + +impl IsInDiary for PathBuf { + + fn is_in_diary(&self, name: &str) -> bool { + self.to_str().map(|s| s.contains(name)).unwrap_or(false) + } + +} +