Commit f367ca18 authored by Jim Turner's avatar Jim Turner
Browse files

Use pattern matching in closure arguments

parent 5641803f
Pipeline #4303288 passed with stage
in 1 minute and 42 seconds
......@@ -34,7 +34,6 @@
//! }
//! ```
use std::borrow::Borrow;
use url::Url;
use super::{util, UrlFilter, UrlFilterError};
......@@ -67,7 +66,7 @@ impl Eloqua {
impl UrlFilter for Eloqua {
fn check(&self, original: &Url) -> bool {
original.query_pairs().any(|pair| ELQ_KEYS.contains(&pair.0.borrow()))
original.query_pairs().any(|(key, _)| ELQ_KEYS.contains(&&(*key)))
}
fn apply(&self, original: &Url) -> Result<Url, UrlFilterError> {
......
......@@ -32,7 +32,6 @@
//! }
//! ```
use std::borrow::Borrow;
use url::Url;
use super::{util, UrlFilter, UrlFilterError};
......@@ -57,7 +56,7 @@ impl GoogleAnalytics {
impl UrlFilter for GoogleAnalytics {
fn check(&self, original: &Url) -> bool {
original.query_pairs().any(|pair| UTM_KEYS.contains(&pair.0.borrow()))
original.query_pairs().any(|(key, _)| UTM_KEYS.contains(&&(*key)))
}
fn apply(&self, original: &Url) -> Result<Url, UrlFilterError> {
......
......@@ -32,7 +32,6 @@
//! }
//! ```
use std::borrow::Borrow;
use url::Url;
use super::{util, UrlFilter, UrlFilterError};
......@@ -54,7 +53,7 @@ impl SubId {
impl UrlFilter for SubId {
fn check(&self, original: &Url) -> bool {
original.query_pairs().any(|pair| SUBID_KEYS.contains(&pair.0.borrow()))
original.query_pairs().any(|(key, _)| SUBID_KEYS.contains(&&(*key)))
}
fn apply(&self, original: &Url) -> Result<Url, UrlFilterError> {
......
......@@ -12,7 +12,7 @@ use super::MissingQueryError;
pub fn query_pair_value<'a, 'b>(url: &'a Url, key: &'b str) -> Result<Cow<'a, str>, MissingQueryError> {
let (_, value) = try!(url.query_pairs()
.find(|pair| pair.0 == key)
.find(|&(ref k, _)| k == key)
.ok_or(MissingQueryError::new(key)));
Ok(value)
}
......@@ -20,10 +20,9 @@ pub fn query_pair_value<'a, 'b>(url: &'a Url, key: &'b str) -> Result<Cow<'a, st
pub fn query_pairs_remove(original: &Url, keys: &[&str]) -> Url {
let mut new = original.clone();
original.query_pairs()
.fold(new.query_pairs_mut().clear(), |new_pairs, orig_pair| {
let (ref key, ref value) = orig_pair;
if !keys.contains(&&(**key)) {
new_pairs.append_pair(key, value)
.fold(new.query_pairs_mut().clear(), |new_pairs, (key, value)| {
if !keys.contains(&&(*key)) {
new_pairs.append_pair(&key, &value)
} else {
new_pairs
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment