summaryrefslogtreecommitdiff
path: root/src/database.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/database.rs')
-rw-r--r--src/database.rs16
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()) {