diff --git a/.travis.yml b/.travis.yml index 41e9e2f..b86d227 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,10 +27,14 @@ before_script: export PATH=$HOME/.local/bin:$PATH # Remove rust-toolchain override for tests - rm rust-toolchain + - rustup component add rustfmt + - rustup component add clippy || cargo install --git https://github.com/rust-lang/rust-clippy/ --force clippy script: + - cargo fmt -- --check + - cargo clippy "${CARGO_FLAGS}" -- -D warnings - | - travis-cargo build -- "${CARGO_FLAGS}" && - travis-cargo test -- "${CARGO_FLAGS}" && + cargo build "${CARGO_FLAGS}" && + cargo test "${CARGO_FLAGS}" && travis-cargo --only nightly doc -- --no-deps "${CARGO_FLAGS}" after_success: - test $CARGO_FLAGS = "--all-features" && travis-cargo --only nightly doc-upload diff --git a/src/fairing.rs b/src/fairing.rs index 991d988..c94e32a 100644 --- a/src/fairing.rs +++ b/src/fairing.rs @@ -58,7 +58,7 @@ fn on_response_wrapper( let result = request.local_cache(|| unreachable!("This should not be executed so late")); - if let &CorsValidation::Failure = result { + if let CorsValidation::Failure = *result { // Nothing else for us to do return Ok(()); } @@ -144,7 +144,7 @@ mod tests { assert!(failed_origins.is_empty()); CorsOptions { - allowed_origins: allowed_origins, + allowed_origins, allowed_methods: vec![Method::Get].into_iter().map(From::from).collect(), allowed_headers: AllowedHeaders::some(&["Authorization", "Accept"]), allow_credentials: true, diff --git a/src/lib.rs b/src/lib.rs index bff0e7b..827340f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -962,7 +962,7 @@ impl Response { /// Consumes the CORS, set expose_headers to /// passed headers and returns changed CORS fn exposed_headers(mut self, headers: &[&str]) -> Self { - self.expose_headers = headers.into_iter().map(|s| s.to_string().into()).collect(); + self.expose_headers = headers.iter().map(|s| s.to_string().into()).collect(); self } @@ -983,7 +983,7 @@ impl Response { /// Consumes the CORS, set allow_headers to /// passed headers and returns changed CORS fn headers(mut self, headers: &[&str]) -> Self { - self.allow_headers = headers.into_iter().map(|s| s.to_string().into()).collect(); + self.allow_headers = headers.iter().map(|s| s.to_string().into()).collect(); self } @@ -1624,7 +1624,7 @@ mod tests { assert!(failed_origins.is_empty()); CorsOptions { - allowed_origins: allowed_origins, + allowed_origins, allowed_methods: vec![http::Method::Get] .into_iter() .map(From::from)