[Auto] lib/entry/category: Fix Clippy warnings

Signed-off-by: flip1995 <hello@philkrones.com>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
flip1995 2019-08-27 10:48:33 +02:00 committed by Matthias Beyer
parent 7c1a8a542c
commit f175d3db17
4 changed files with 9 additions and 9 deletions

View file

@ -52,7 +52,7 @@ impl Category for Entry {
.read_string(CATEGORY_REGISTER_NAME_FIELD_PATH) .read_string(CATEGORY_REGISTER_NAME_FIELD_PATH)
.context(format_err!("Failed to read header at '{}'", CATEGORY_REGISTER_NAME_FIELD_PATH)) .context(format_err!("Failed to read header at '{}'", CATEGORY_REGISTER_NAME_FIELD_PATH))
.map_err(Error::from)? .map_err(Error::from)?
.ok_or_else(|| Error::from(err_msg("Category name missing"))) .ok_or_else(|| err_msg("Category name missing"))
} }
fn get_entries<'a>(&self, store: &'a Store) -> Result<CategoryEntryIterator<'a>> { fn get_entries<'a>(&self, store: &'a Store) -> Result<CategoryEntryIterator<'a>> {

View file

@ -65,10 +65,10 @@ impl EntryCategory for Entry {
trace!("Setting category '{}' checked", s); trace!("Setting category '{}' checked", s);
let mut category = register let mut category = register
.get_category_by_name(s)? .get_category_by_name(s)?
.ok_or_else(|| Error::from(err_msg("Category does not exist")))?; .ok_or_else(|| err_msg("Category does not exist"))?;
let _ = self.set_category(s)?; self.set_category(s)?;
let _ = self.add_link(&mut category)?; self.add_link(&mut category)?;
Ok(()) Ok(())
} }
@ -77,7 +77,7 @@ impl EntryCategory for Entry {
trace!("Getting category from '{}'", self.get_location()); trace!("Getting category from '{}'", self.get_location());
self.get_header() self.get_header()
.read_string("category.value")? .read_string("category.value")?
.ok_or_else(|| Error::from(err_msg("Category name missing"))) .ok_or_else(|| err_msg("Category name missing"))
} }
fn has_category(&self) -> Result<bool> { fn has_category(&self) -> Result<bool> {

View file

@ -103,7 +103,7 @@ impl<'a> Iterator for CategoryEntryIterator<'a> {
let getter = |next| -> Result<(String, FileLockEntry<'a>)> { let getter = |next| -> Result<(String, FileLockEntry<'a>)> {
let entry = self.0 let entry = self.0
.get(next)? .get(next)?
.ok_or_else(|| Error::from(err_msg("Store read error")))?; .ok_or_else(|| err_msg("Store read error"))?;
Ok((entry.get_category()?, entry)) Ok((entry.get_category()?, entry))
}; };

View file

@ -34,7 +34,7 @@ use failure::err_msg;
use crate::iter::CategoryNameIter; use crate::iter::CategoryNameIter;
use crate::category::IsCategory; use crate::category::IsCategory;
pub const CATEGORY_REGISTER_NAME_FIELD_PATH : &'static str = "category.register.name"; pub const CATEGORY_REGISTER_NAME_FIELD_PATH : &str = "category.register.name";
/// Extension on the Store to make it a register for categories /// Extension on the Store to make it a register for categories
/// ///
@ -92,12 +92,12 @@ impl CategoryStore for Store {
{ {
let mut category = self.get(sid.clone())? let mut category = self.get(sid.clone())?
.ok_or_else(|| Error::from(err_msg("Category does not exist"))) .ok_or_else(|| err_msg("Category does not exist"))
.map_err(Error::from)?; .map_err(Error::from)?;
for entry in category.get_entries(self)? { for entry in category.get_entries(self)? {
let mut entry = entry?; let mut entry = entry?;
let _ = category.remove_link(&mut entry)?; category.remove_link(&mut entry)?;
} }
} }