1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-30 08:38:16 +02:00

clippy warnings; fmt

This commit is contained in:
Nikolay Kim
2018-04-28 22:55:47 -07:00
parent a38c3985f6
commit de49796fd1
67 changed files with 988 additions and 1866 deletions

View File

@@ -6,8 +6,8 @@ use std::ops::{Deref, DerefMut};
use std::rc::Rc;
use mime;
use serde::Serialize;
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde_json;
use error::{Error, JsonPayloadError, PayloadError};
@@ -308,10 +308,7 @@ where
self.fut = Some(Box::new(fut));
}
self.fut
.as_mut()
.expect("JsonBody could not be used second time")
.poll()
self.fut.as_mut().expect("JsonBody could not be used second time").poll()
}
}
@@ -362,10 +359,7 @@ mod tests {
fn test_json_body() {
let req = HttpRequest::default();
let mut json = req.json::<MyObject>();
assert_eq!(
json.poll().err().unwrap(),
JsonPayloadError::ContentType
);
assert_eq!(json.poll().err().unwrap(), JsonPayloadError::ContentType);
let mut req = HttpRequest::default();
req.headers_mut().insert(
@@ -373,20 +367,15 @@ mod tests {
header::HeaderValue::from_static("application/text"),
);
let mut json = req.json::<MyObject>();
assert_eq!(
json.poll().err().unwrap(),
JsonPayloadError::ContentType
);
assert_eq!(json.poll().err().unwrap(), JsonPayloadError::ContentType);
let mut req = HttpRequest::default();
req.headers_mut().insert(
header::CONTENT_TYPE,
header::HeaderValue::from_static("application/json"),
);
req.headers_mut().insert(
header::CONTENT_LENGTH,
header::HeaderValue::from_static("10000"),
);
req.headers_mut()
.insert(header::CONTENT_LENGTH, header::HeaderValue::from_static("10000"));
let mut json = req.json::<MyObject>().limit(100);
assert_eq!(json.poll().err().unwrap(), JsonPayloadError::Overflow);
@@ -395,12 +384,9 @@ mod tests {
header::CONTENT_TYPE,
header::HeaderValue::from_static("application/json"),
);
req.headers_mut().insert(
header::CONTENT_LENGTH,
header::HeaderValue::from_static("16"),
);
req.payload_mut()
.unread_data(Bytes::from_static(b"{\"name\": \"test\"}"));
req.headers_mut()
.insert(header::CONTENT_LENGTH, header::HeaderValue::from_static("16"));
req.payload_mut().unread_data(Bytes::from_static(b"{\"name\": \"test\"}"));
let mut json = req.json::<MyObject>();
assert_eq!(
json.poll().ok().unwrap(),
@@ -417,12 +403,7 @@ mod tests {
let mut handler = With::new(|data: Json<MyObject>| data, cfg);
let req = HttpRequest::default();
let err = handler
.handle(req)
.as_response()
.unwrap()
.error()
.is_some();
let err = handler.handle(req).as_response().unwrap().error().is_some();
assert!(err);
let mut req = HttpRequest::default();
@@ -430,18 +411,10 @@ mod tests {
header::CONTENT_TYPE,
header::HeaderValue::from_static("application/json"),
);
req.headers_mut().insert(
header::CONTENT_LENGTH,
header::HeaderValue::from_static("16"),
);
req.payload_mut()
.unread_data(Bytes::from_static(b"{\"name\": \"test\"}"));
let ok = handler
.handle(req)
.as_response()
.unwrap()
.error()
.is_none();
req.headers_mut()
.insert(header::CONTENT_LENGTH, header::HeaderValue::from_static("16"));
req.payload_mut().unread_data(Bytes::from_static(b"{\"name\": \"test\"}"));
let ok = handler.handle(req).as_response().unwrap().error().is_none();
assert!(ok)
}
}