diff options
author | Andre Bogus <bogusandre@gmail.com> | 2016-05-03 23:10:32 +0200 |
---|---|---|
committer | Andre Bogus <bogusandre@gmail.com> | 2016-05-13 22:27:53 +0200 |
commit | 981707c9c959668e09f83926f6dafa296e84ebf0 (patch) | |
tree | b534d8acea0c0a7d0b27c81963fe62e075f1709b /libimagnotes | |
parent | 7a46df312549d6bf97b6ebcb40599061c57ca55e (diff) |
more style adaptations
again following clippy
Diffstat (limited to 'libimagnotes')
-rw-r--r-- | libimagnotes/src/error.rs | 17 | ||||
-rw-r--r-- | libimagnotes/src/note.rs | 12 |
2 files changed, 14 insertions, 15 deletions
diff --git a/libimagnotes/src/error.rs b/libimagnotes/src/error.rs index b55659f6..ec1f5535 100644 --- a/libimagnotes/src/error.rs +++ b/libimagnotes/src/error.rs @@ -1,6 +1,5 @@ use std::error::Error; use std::fmt::Error as FmtError; -use std::clone::Clone; use std::fmt::{Display, Formatter}; /** @@ -16,11 +15,11 @@ pub enum NoteErrorKind { } fn note_error_type_as_str(e: &NoteErrorKind) -> &'static str { - match e { - &NoteErrorKind::StoreWriteError => "Error writing store", - &NoteErrorKind::StoreReadError => "Error reading store", - &NoteErrorKind::HeaderTypeError => "Header type error", - &NoteErrorKind::NoteToEntryConversion => "Error converting Note instance to Entry instance", + match *e { + NoteErrorKind::StoreWriteError => "Error writing store", + NoteErrorKind::StoreReadError => "Error reading store", + NoteErrorKind::HeaderTypeError => "Header type error", + NoteErrorKind::NoteToEntryConversion => "Error converting Note instance to Entry instance", } } @@ -58,7 +57,7 @@ impl NoteError { * Get the error type of this NoteError */ pub fn err_type(&self) -> NoteErrorKind { - self.err_type.clone() + self.err_type } } @@ -66,7 +65,7 @@ impl NoteError { impl Display for NoteError { fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> { - try!(write!(fmt, "[{}]", note_error_type_as_str(&self.err_type.clone()))); + try!(write!(fmt, "[{}]", note_error_type_as_str(&self.err_type))); Ok(()) } @@ -75,7 +74,7 @@ impl Display for NoteError { impl Error for NoteError { fn description(&self) -> &str { - note_error_type_as_str(&self.err_type.clone()) + note_error_type_as_str(&self.err_type) } fn cause(&self) -> Option<&Error> { diff --git a/libimagnotes/src/note.rs b/libimagnotes/src/note.rs index 2728b768..8847b888 100644 --- a/libimagnotes/src/note.rs +++ b/libimagnotes/src/note.rs @@ -10,7 +10,7 @@ use libimagstore::storeid::StoreId; use libimagstore::storeid::StoreIdIterator; use libimagstore::store::FileLockEntry; use libimagstore::store::Store; -use libimagentrytag::tag::Tag; +use libimagentrytag::tag::{Tag, TagSlice}; use libimagentrytag::tagable::Tagable; use libimagentrytag::result::Result as TagResult; @@ -124,7 +124,7 @@ impl<'a> Tagable for Note<'a> { self.entry.get_tags() } - fn set_tags(&mut self, ts: Vec<Tag>) -> TagResult<()> { + fn set_tags(&mut self, ts: &[Tag]) -> TagResult<()> { self.entry.set_tags(ts) } @@ -136,23 +136,23 @@ impl<'a> Tagable for Note<'a> { self.entry.remove_tag(t) } - fn has_tag(&self, t: &Tag) -> TagResult<bool> { + fn has_tag(&self, t: TagSlice) -> TagResult<bool> { self.entry.has_tag(t) } - fn has_tags(&self, ts: &Vec<Tag>) -> TagResult<bool> { + fn has_tags(&self, ts: &[Tag]) -> TagResult<bool> { self.entry.has_tags(ts) } } trait FromStoreId { - fn from_storeid<'a>(&'a Store, StoreId) -> Result<Note<'a>>; + fn from_storeid(&Store, StoreId) -> Result<Note>; } impl<'a> FromStoreId for Note<'a> { - fn from_storeid<'b>(store: &'b Store, id: StoreId) -> Result<Note<'b>> { + fn from_storeid(store: &Store, id: StoreId) -> Result<Note> { debug!("Loading note from storeid: '{:?}'", id); match store.retrieve(id) { Err(e) => Err(NE::new(NEK::StoreReadError, Some(Box::new(e)))), |