From a6bceb230159b18f24da579fcb990d5268bde1df Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Sat, 20 Jun 2020 21:38:27 -0400 Subject: Lint code. --- src/database.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/database.rs') diff --git a/src/database.rs b/src/database.rs index e5ea02f..5591d6a 100644 --- a/src/database.rs +++ b/src/database.rs @@ -49,18 +49,16 @@ pub fn parse_query>(query_string: T) -> Result { .as_ref() .split_whitespace() .map(|part| { - if part.starts_with("-") { + if part.starts_with('-') { if part.len() >= 9 && &part[1..10] == "filename:" { Filename(IsNot(String::from(&part[10..]))) } else { Tag(IsNot(String::from(&part[1..]))) } + } else if part.len() >= 9 && &part[..9] == "filename:" { + Filename(Is(String::from(&part[9..]))) } else { - if part.len() >= 9 && &part[..9] == "filename:" { - Filename(Is(String::from(&part[9..]))) - } else { - Tag(Is(String::from(part))) - } + Tag(Is(String::from(part))) } }) .collect()) @@ -151,7 +149,7 @@ impl TagDatabase { } /// Index the file at `path` in the tag database. - pub fn add_file(&self, path: T, tags: &Vec) -> Result + pub fn add_file(&self, path: T, tags: &[S]) -> Result where T: AsRef, S: AsRef, @@ -217,7 +215,7 @@ impl TagDatabase { /// /// If any tag lacks a row in the database, it will be created. The contents /// of `tags` should not contain wildcardcard expressions. - pub fn tag_file>(&self, id: i64, tags: &Vec) -> Result<()> { + pub fn tag_file>(&self, id: i64, tags: &[T]) -> Result<()> { for tag in tags.iter() { // Ensure that a row for `tag` into the database. if self.tag_id(tag.as_ref()).is_err() { @@ -235,7 +233,7 @@ impl TagDatabase { /// Remove all of `tags` from the file named by `id`. /// /// The contents of `tags` can contain wildcardcard expressions. - pub fn untag_file>(&self, id: i64, tags: &Vec) -> Result<()> { + pub fn untag_file>(&self, id: i64, tags: &[T]) -> Result<()> { for tag in tags.iter() { // Silently skip any tags which do not exist in the database. if let Ok(tags) = self.tag_ids(tag.as_ref()) { -- cgit v1.3