diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-06-20 21:38:27 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-06-20 21:38:27 -0400 |
| commit | a6bceb230159b18f24da579fcb990d5268bde1df (patch) | |
| tree | f6e93380acf7b6196cc867fff9090854feae17cd /src/database.rs | |
| parent | 5d44144716342013afe7f493c78984773cb132b5 (diff) | |
Lint code.
Diffstat (limited to 'src/database.rs')
| -rw-r--r-- | src/database.rs | 16 |
1 files changed, 7 insertions, 9 deletions
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<T: AsRef<str>>(query_string: T) -> Result<Query> { .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<T, S>(&self, path: T, tags: &Vec<S>) -> Result<File> + pub fn add_file<T, S>(&self, path: T, tags: &[S]) -> Result<File> where T: AsRef<Path>, S: AsRef<str>, @@ -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<T: AsRef<str>>(&self, id: i64, tags: &Vec<T>) -> Result<()> { + pub fn tag_file<T: AsRef<str>>(&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<T: AsRef<str>>(&self, id: i64, tags: &Vec<T>) -> Result<()> { + pub fn untag_file<T: AsRef<str>>(&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()) { |