diff options
| author | Jokler <jokler.contact@gmail.com> | 2018-09-21 00:59:44 +0200 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2018-09-21 00:59:44 +0200 |
| commit | 9401a62004f3ac7313f6bf12d2649d5af61835c5 (patch) | |
| tree | b39a4e4c700039bb2e59cf514d1eeb695e1bb8a1 /src/plugins/quote/database.rs | |
| parent | 625ca41cf54bac0268f7bde9d7ad9017c03d5919 (diff) | |
| download | frippy-9401a62004f3ac7313f6bf12d2649d5af61835c5.tar.gz frippy-9401a62004f3ac7313f6bf12d2649d5af61835c5.zip | |
Quote: Ignore trailing space when no index was specified
Diffstat (limited to 'src/plugins/quote/database.rs')
| -rw-r--r-- | src/plugins/quote/database.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/quote/database.rs b/src/plugins/quote/database.rs index 6ad08a0..49d6058 100644 --- a/src/plugins/quote/database.rs +++ b/src/plugins/quote/database.rs @@ -46,7 +46,9 @@ pub trait Database: Send + Sync { } // HashMap -impl<S: ::std::hash::BuildHasher + Send + Sync> Database for HashMap<(String, String, i32), Quote, S> { +impl<S: ::std::hash::BuildHasher + Send + Sync> Database + for HashMap<(String, String, i32), Quote, S> +{ fn insert_quote(&mut self, quote: &NewQuote) -> Result<(), QuoteError> { let quote = Quote { quotee: quote.quotee.to_owned(), @@ -66,13 +68,17 @@ impl<S: ::std::hash::BuildHasher + Send + Sync> Database for HashMap<(String, St } fn get_quote(&self, quotee: &str, channel: &str, idx: i32) -> Result<Quote, QuoteError> { - Ok(self.get(&(quotee.to_owned(), channel.to_owned(), idx)) + Ok(self + .get(&(quotee.to_owned(), channel.to_owned(), idx)) .cloned() .ok_or(ErrorKind::NotFound)?) } fn count_quotes(&self, quotee: &str, channel: &str) -> Result<i32, QuoteError> { - Ok(self.iter().filter(|&(&(ref n, ref c, _), _)| n == quotee && c == channel).count() as i32) + Ok(self + .iter() + .filter(|&(&(ref n, ref c, _), _)| n == quotee && c == channel) + .count() as i32) } } |
