Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings and errors #1778

Merged
merged 17 commits into from
Apr 22, 2019
Merged
10 changes: 5 additions & 5 deletions download/tests/download-curl-resume.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg(feature = "curl-backend")]

use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;

use url::Url;
Expand Down Expand Up @@ -35,7 +36,7 @@ fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {

let from_url = format!("http://{}", addr).parse().unwrap();

let callback_partial = Mutex::new(false);
let callback_partial = AtomicBool::new(false);
let callback_len = Mutex::new(None);
let received_in_callback = Mutex::new(Vec::new());

Expand All @@ -47,9 +48,8 @@ fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {
Some(&|msg| {
match msg {
Event::ResumingPartialDownload => {
let mut flag = callback_partial.lock().unwrap();
assert!(!*flag);
*flag = true;
assert!(!callback_partial.load(Ordering::SeqCst));
callback_partial.store(true, Ordering::SeqCst);
kinnison marked this conversation as resolved.
Show resolved Hide resolved
}
Event::DownloadContentLengthReceived(len) => {
let mut flag = callback_len.lock().unwrap();
Expand All @@ -68,7 +68,7 @@ fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {
)
.expect("Test download failed");

assert!(*callback_partial.lock().unwrap());
assert!(callback_partial.into_inner());
assert_eq!(*callback_len.lock().unwrap(), Some(5));
let observed_bytes = received_in_callback.into_inner().unwrap();
assert_eq!(observed_bytes, vec![b'1', b'2', b'3', b'4', b'5']);
Expand Down
10 changes: 5 additions & 5 deletions download/tests/download-reqwest-resume.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg(feature = "reqwest-backend")]

use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;

use url::Url;
Expand Down Expand Up @@ -35,7 +36,7 @@ fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {

let from_url = format!("http://{}", addr).parse().unwrap();

let callback_partial = Mutex::new(false);
let callback_partial = AtomicBool::new(false);
let callback_len = Mutex::new(None);
let received_in_callback = Mutex::new(Vec::new());

Expand All @@ -47,9 +48,8 @@ fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {
Some(&|msg| {
match msg {
Event::ResumingPartialDownload => {
let mut flag = callback_partial.lock().unwrap();
assert!(!*flag);
*flag = true;
assert!(!callback_partial.load(Ordering::SeqCst));
callback_partial.store(true, Ordering::SeqCst);
kinnison marked this conversation as resolved.
Show resolved Hide resolved
}
Event::DownloadContentLengthReceived(len) => {
let mut flag = callback_len.lock().unwrap();
Expand All @@ -68,7 +68,7 @@ fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {
)
.expect("Test download failed");

assert!(*callback_partial.lock().unwrap());
assert!(callback_partial.into_inner());
assert_eq!(*callback_len.lock().unwrap(), Some(5));
let observed_bytes = received_in_callback.into_inner().unwrap();
assert_eq!(observed_bytes, vec![b'1', b'2', b'3', b'4', b'5']);
Expand Down