From 777c9e59f142cb89f69bc8a2ecdeaad88ff44708 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 27 Aug 2019 10:46:01 +0200 Subject: [PATCH] [Auto] lib/domain/diary: Fix Clippy warnings Signed-off-by: flip1995 Signed-off-by: Matthias Beyer --- lib/domain/libimagdiary/src/diary.rs | 5 ++--- lib/domain/libimagdiary/src/diaryid.rs | 10 +++++----- lib/domain/libimagdiary/src/iter.rs | 8 ++++---- lib/domain/libimagdiary/src/viewer.rs | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/domain/libimagdiary/src/diary.rs b/lib/domain/libimagdiary/src/diary.rs index b268b0b6..17bfdbed 100644 --- a/lib/domain/libimagdiary/src/diary.rs +++ b/lib/domain/libimagdiary/src/diary.rs @@ -68,7 +68,7 @@ impl Diary for Store { let id = DiaryId::new(String::from(diary_name), ndt.year(), ndt.month(), ndt.day(), 0, 0, 0); let mut entry = self.retrieve(id)?; - let _ = entry.set_isflag::()?; + entry.set_isflag::()?; Ok(entry) } @@ -88,7 +88,7 @@ impl Diary for Store { ndt.second()); let mut entry = self.retrieve(id)?; - let _ = entry.set_isflag::()?; + entry.set_isflag::()?; Ok(entry) } @@ -131,7 +131,6 @@ impl Diary for Store { }, } }) - .into_iter() .rev() .next() } diff --git a/lib/domain/libimagdiary/src/diaryid.rs b/lib/domain/libimagdiary/src/diaryid.rs index 727bb52d..c842a15c 100644 --- a/lib/domain/libimagdiary/src/diaryid.rs +++ b/lib/domain/libimagdiary/src/diaryid.rs @@ -49,7 +49,7 @@ impl DiaryId { pub fn new(name: String, y: i32, m: u32, d: u32, h: u32, min: u32, sec: u32) -> DiaryId { DiaryId { - name: name, + name, year: y, month: m, day: d, @@ -202,7 +202,7 @@ fn component_to_str<'a>(com: Component<'a>) -> Result<&'a str> { Component::Normal(s) => Some(s), _ => None, }.and_then(|s| s.to_str()) - .ok_or_else(|| Error::from(err_msg("ID Parse error"))) + .ok_or_else(|| err_msg("ID Parse error")) } impl FromStoreId for DiaryId { @@ -215,7 +215,7 @@ impl FromStoreId for DiaryId { fn next_component<'a>(components: &'a mut Rev) -> Result<&'a str> { components.next() - .ok_or_else(|| Error::from(err_msg("ID parse error"))) + .ok_or_else(|| err_msg("ID parse error")) .and_then(component_to_str) } @@ -223,7 +223,7 @@ impl FromStoreId for DiaryId { trace!("Found components: {:?}", cmps); let (hour, minute, second) = next_component(&mut cmps).and_then(|time| { - let mut time = time.split(":"); + let mut time = time.split(':'); let hour = time.next().and_then(|s| FromStr::from_str(s).ok()); let minute = time.next().and_then(|s| FromStr::from_str(s).ok()); let second = time.next().and_then(|s| FromStr::from_str(s).ok()); @@ -235,7 +235,7 @@ impl FromStoreId for DiaryId { match (hour, minute, second) { (Some(h), Some(m), Some(s)) => Ok((h, m, s)), - _ => return Err(Error::from(err_msg("ID Parse error"))), + _ => Err(err_msg("ID Parse error")), } })?; diff --git a/lib/domain/libimagdiary/src/iter.rs b/lib/domain/libimagdiary/src/iter.rs index 147aaf60..38850cec 100644 --- a/lib/domain/libimagdiary/src/iter.rs +++ b/lib/domain/libimagdiary/src/iter.rs @@ -27,7 +27,7 @@ use libimagstore::storeid::StoreId; use crate::is_in_diary::IsInDiary; use failure::Fallible as Result; -use failure::Error; + use failure::err_msg; /// A iterator for iterating over diary entries @@ -54,7 +54,7 @@ impl DiaryEntryIterator { pub fn new(diaryname: String, iter: StoreIdIterator) -> DiaryEntryIterator { DiaryEntryIterator { name: diaryname, - iter: iter, + iter, year: None, month: None, @@ -149,8 +149,8 @@ impl Iterator for DiaryNameIterator { .and_then(|s| { s.split("diary/") .nth(1) - .and_then(|n| n.split("/").nth(0).map(String::from)) - .ok_or_else(|| Error::from(err_msg("Error finding diary name"))) + .and_then(|n| n.split('/').nth(0).map(String::from)) + .ok_or_else(|| err_msg("Error finding diary name")) })); }, } diff --git a/lib/domain/libimagdiary/src/viewer.rs b/lib/domain/libimagdiary/src/viewer.rs index f4407661..fccec42c 100644 --- a/lib/domain/libimagdiary/src/viewer.rs +++ b/lib/domain/libimagdiary/src/viewer.rs @@ -82,7 +82,7 @@ impl Viewer for DiaryViewer { for (id, entry) in entries.into_iter() { writeln!(sink, "{} :\n", id)?; - let _ = self.0.view_entry(entry.deref(), sink)?; + self.0.view_entry(entry.deref(), sink)?; writeln!(sink, "\n---\n")?; }