From 9a1073aae23e03a8d2e00daf428acdb9778d8657 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 17 Apr 2019 11:39:54 -0400 Subject: [PATCH] Remove a bunch of redundant parens --- src/query_builder.rs | 47 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/query_builder.rs b/src/query_builder.rs index 5de3bb4..e20f144 100644 --- a/src/query_builder.rs +++ b/src/query_builder.rs @@ -160,7 +160,7 @@ impl QueryBuilder { /// // Search for a value that has "foo" in it /// qb.like("field", String::from("foo"), LikeWildcard::Both); /// ``` - pub fn like(&mut self, field: &str, value: (impl Any), position: LikeWildcard) -> &mut Self { + pub fn like(&mut self, field: &str, value: impl Any, position: LikeWildcard) -> &mut Self { self._like(field, value, position, "LIKE", "AND") } @@ -168,7 +168,7 @@ impl QueryBuilder { pub fn or_like( &mut self, field: &str, - value: (impl Any), + value: impl Any, position: LikeWildcard, ) -> &mut Self { self._like(field, value, position, "LIKE", "OR") @@ -178,7 +178,7 @@ impl QueryBuilder { pub fn not_like( &mut self, field: &str, - value: (impl Any), + value: impl Any, position: LikeWildcard, ) -> &mut Self { self._like(field, value, position, "NOT LIKE", "AND") @@ -188,7 +188,7 @@ impl QueryBuilder { pub fn or_not_like( &mut self, field: &str, - value: (impl Any), + value: impl Any, position: LikeWildcard, ) -> &mut Self { self._like(field, value, position, "NOT LIKE", "OR") @@ -209,12 +209,12 @@ impl QueryBuilder { /// // Other operators can be used with a separating space /// qb.having("clues >=", vec![Box::new(4)]); /// ``` - pub fn having(&mut self, key: &str, value: Vec<(impl Any)>) -> &mut Self { + pub fn having(&mut self, key: &str, value: Vec) -> &mut Self { self._having(key, value, "AND") } /// Add a `having` clause to the query, prefixed with an `or` - pub fn or_having(&mut self, key: &str, value: Vec<(impl Any)>) -> &mut Self { + pub fn or_having(&mut self, key: &str, value: Vec) -> &mut Self { self._having(key, value, "OR") } @@ -222,11 +222,6 @@ impl QueryBuilder { // ! 'Where' methods // -------------------------------------------------------------------------- - /// Alias method for `r#where`. - pub fn filter(&mut self, key: &str, value: (impl Any)) -> &mut Self { - self.r#where(key, value) - } - /// Specify a condition for the `where` clause of the query. Can be called /// multiple times, which will then add additional where conditions, prefixed /// with 'AND'. @@ -240,32 +235,38 @@ impl QueryBuilder { /// // Other operators can be used with a separating space /// qb.r#where("key >", Box::new(4)); /// ``` - pub fn r#where(&mut self, key: &str, value: (impl Any)) -> &mut Self { + pub fn r#where(&mut self, key: &str, value: impl Any) -> &mut Self { self._where_string(key, value, "AND") } + /// Alias method for `where`, as using the `where` method requires + /// using the raw identifier `r#where`. + pub fn filter(&mut self, key: &str, value: impl Any) -> &mut Self { + self.r#where(key, value) + } + /// Specify a condition for the `where` clause of the query, prefixed with `or` - pub fn or_where(&mut self, key: &str, value: (impl Any)) -> &mut Self { + pub fn or_where(&mut self, key: &str, value: impl Any) -> &mut Self { self._where_string(key, value, "OR") } /// Specify a `where in` clause for the query - pub fn where_in(&mut self, key: &str, values: Vec<(impl Any)>) -> &mut Self { + pub fn where_in(&mut self, key: &str, values: Vec) -> &mut Self { self._where_in(key, values, "IN", "AND") } /// Specify a `where in` clause for the query, prefixed with `or` - pub fn or_where_in(&mut self, key: &str, values: Vec<(impl Any)>) -> &mut Self { + pub fn or_where_in(&mut self, key: &str, values: Vec) -> &mut Self { self._where_in(key, values, "IN", "OR") } /// Specify a `where not in` clause for the query - pub fn where_not_in(&mut self, key: &str, values: Vec<(impl Any)>) -> &mut Self { + pub fn where_not_in(&mut self, key: &str, values: Vec) -> &mut Self { self._where_in(key, values, "NOT IN", "AND") } /// Specify a `where not in` clause for the query, prefixed with `or` - pub fn or_where_not_in(&mut self, key: &str, values: Vec<(impl Any)>) -> &mut Self { + pub fn or_where_not_in(&mut self, key: &str, values: Vec) -> &mut Self { self._where_in(key, values, "NOT IN", "OR") } @@ -274,7 +275,7 @@ impl QueryBuilder { // -------------------------------------------------------------------------- /// Set a key and value for an insert or update query - pub fn set(&mut self, key: &str, value: (impl Any)) -> &mut Self { + pub fn set(&mut self, key: &str, value: impl Any) -> &mut Self { // @TODO figure a way to make this easier to use let key = self.driver.quote_identifier(key); self.state.append_set_array_keys(&key).append_values(Box::new(value)); @@ -283,7 +284,7 @@ impl QueryBuilder { } /// Set a map of data for an insert or update query - pub fn set_map(&mut self, data: HashMap) -> &mut Self { + pub fn set_map(&mut self, data: HashMap) -> &mut Self { for (key, value) in data { self.set(&key, value); } @@ -514,7 +515,7 @@ impl QueryBuilder { fn _like( &mut self, field: &str, - value: (impl Any), + value: impl Any, position: LikeWildcard, like: &str, conj: &str, @@ -540,7 +541,7 @@ impl QueryBuilder { self } - fn _having(&mut self, key: &str, values: Vec<(impl Any)>, conj: &str) -> &mut Self { + fn _having(&mut self, key: &str, values: Vec, conj: &str) -> &mut Self { let keys = self._where(key, values); for k in keys { @@ -568,7 +569,7 @@ impl QueryBuilder { self } - fn _where(&mut self, key: &str, values: Vec<(impl Any)>) -> Vec { + fn _where(&mut self, key: &str, values: Vec) -> Vec { for x in values { self.state.append_where_values(Box::new(x)); } @@ -579,7 +580,7 @@ impl QueryBuilder { fn _where_in( &mut self, key: &str, - values: Vec<(impl Any)>, + values: Vec, in_str: &str, conj: &str, ) -> &mut Self {