Skip to content

Commit 3655473

Browse files
committed
style: cargo fmt
1 parent 53c310a commit 3655473

File tree

4 files changed

+45
-28
lines changed

4 files changed

+45
-28
lines changed

src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@
3232
//! /// Will be important for validation....
3333
//! use rocket_validation::{Validate, Validated};
3434
//!
35-
//! #[derive(Debug, Deserialize, Serialize, Validate)] /// Implements `Validate`
35+
//! #[derive(Debug, Deserialize, Serialize, Validate)]
36+
//! /// Implements `Validate`
3637
//! #[serde(crate = "rocket::serde")]
3738
//! pub struct HelloData {
38-
//! #[validate(length(min = 1))] /// Your validation annotation
39+
//! #[validate(length(min = 1))]
40+
//! /// Your validation annotation
3941
//! name: String,
40-
//! #[validate(range(min = 0, max = 100))] /// Your validation annotation
42+
//! #[validate(range(min = 0, max = 100))]
43+
//! /// Your validation annotation
4144
//! age: u8,
4245
//! }
4346
//!

tests/test_form.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
21
#[macro_use]
32
extern crate rocket;
43

5-
use rocket::local::blocking::LocalResponse;
6-
use rocket::serde::{json::Json, Deserialize, Serialize};
4+
use rocket::{
5+
form::Form,
6+
local::blocking::LocalResponse,
7+
serde::{json::Json, Deserialize, Serialize},
8+
};
79
use rocket_validation::{Validate, Validated};
8-
use rocket::form::Form;
910

1011
#[derive(Copy, Clone, Debug, Serialize, Deserialize, Validate, FromForm)]
1112
#[serde(crate = "rocket::serde")]
@@ -31,18 +32,21 @@ fn rocket() -> _ {
3132
rocket::build().mount("/", routes![hello, validated_hello])
3233
}
3334

34-
use rocket::http::ContentType;
35-
use rocket::http::Status;
36-
use rocket::local::blocking::Client;
37-
use rocket::http::Header;
35+
use rocket::{
36+
http::{ContentType, Header, Status},
37+
local::blocking::Client,
38+
};
3839

3940
#[test]
4041
pub fn valid_post() {
4142
let client = Client::tracked(rocket()).unwrap();
4243

4344
let header = Header::new("content-type", "application/x-www-form-urlencoded");
4445

45-
let req = client.post("/hello").header(header).body("name=Chris&age=18");
46+
let req = client
47+
.post("/hello")
48+
.header(header)
49+
.body("name=Chris&age=18");
4650

4751
let response: LocalResponse = req.dispatch();
4852

@@ -51,7 +55,6 @@ pub fn valid_post() {
5155
assert_eq!(response.content_type(), Some(ContentType::JSON));
5256
}
5357

54-
5558
#[test]
5659
pub fn invalid_short_name() {
5760
let client = Client::tracked(rocket()).unwrap();
@@ -71,7 +74,10 @@ pub fn invalid_min_age() {
7174
let client = Client::tracked(rocket()).unwrap();
7275
let header = Header::new("content-type", "application/x-www-form-urlencoded");
7376

74-
let req = client.post("/hello").header(header).body("name=Chris&age=0");
77+
let req = client
78+
.post("/hello")
79+
.header(header)
80+
.body("name=Chris&age=0");
7581

7682
let response: LocalResponse = req.dispatch();
7783

@@ -84,10 +90,13 @@ pub fn invalid_max_age() {
8490
let client = Client::tracked(rocket()).unwrap();
8591
let header = Header::new("content-type", "application/x-www-form-urlencoded");
8692

87-
let req = client.post("/hello").header(header).body("name=Chris&age=102");
93+
let req = client
94+
.post("/hello")
95+
.header(header)
96+
.body("name=Chris&age=102");
8897

8998
let response: LocalResponse = req.dispatch();
9099

91100
assert_eq!(response.status(), Status::UnprocessableEntity);
92101
assert_eq!(response.content_type(), Some(ContentType::HTML));
93-
}
102+
}

tests/test_json.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#[macro_use]
22
extern crate rocket;
33

4-
use rocket::local::blocking::LocalResponse;
5-
use rocket::serde::{json::Json, Deserialize, Serialize};
4+
use rocket::{
5+
local::blocking::LocalResponse,
6+
serde::{json::Json, Deserialize, Serialize},
7+
};
68
use rocket_validation::{Validate, Validated};
79

810
#[derive(Copy, Clone, Debug, Serialize, Deserialize, Validate, FromForm)]
@@ -29,9 +31,10 @@ fn rocket() -> _ {
2931
rocket::build().mount("/", routes![hello, validated_hello])
3032
}
3133

32-
use rocket::http::ContentType;
33-
use rocket::http::Status;
34-
use rocket::local::blocking::Client;
34+
use rocket::{
35+
http::{ContentType, Status},
36+
local::blocking::Client,
37+
};
3538

3639
#[test]
3740
pub fn valid_get() {

tests/test_query.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
21
#[macro_use]
32
extern crate rocket;
43

5-
use rocket::local::blocking::LocalResponse;
6-
use rocket::serde::{json::Json, Deserialize, Serialize};
4+
use rocket::{
5+
local::blocking::LocalResponse,
6+
serde::{json::Json, Deserialize, Serialize},
7+
};
78
use rocket_validation::{Validate, Validated};
89

910
#[derive(Copy, Clone, Debug, Serialize, Deserialize, Validate, FromForm)]
@@ -30,9 +31,10 @@ fn rocket() -> _ {
3031
rocket::build().mount("/", routes![hello, validated_hello])
3132
}
3233

33-
use rocket::http::ContentType;
34-
use rocket::http::Status;
35-
use rocket::local::blocking::Client;
34+
use rocket::{
35+
http::{ContentType, Status},
36+
local::blocking::Client,
37+
};
3638

3739
#[test]
3840
pub fn valid_get() {
@@ -92,4 +94,4 @@ pub fn invalid_max_age() {
9294

9395
assert_eq!(response.status(), Status::NotFound);
9496
assert_eq!(response.content_type(), Some(ContentType::HTML));
95-
}
97+
}

0 commit comments

Comments
 (0)