Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Mar 1, 2018
1 parent ea16466 commit 5fd91f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
22 changes: 8 additions & 14 deletions examples/sessions/custom_data_type/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ fn get_handler(mut state: State) -> (State, Response) {
};

let body = match &maybe_visit_data {
&Some(ref visit_data) => {
format!(
&Some(ref visit_data) => format!(
"You have visited this page {} time(s) before. Your last visit was {}.\n",
visit_data.count,
visit_data.last_visit,
)
}
visit_data.count, visit_data.last_visit,
),
&None => "You have never visited this page before.\n".to_owned(),
};
let res = {
Expand Down Expand Up @@ -75,11 +72,9 @@ fn router() -> Router {
// connections. This should not be done in real applications.
.insecure();
let (chain, pipelines) = single_pipeline(new_pipeline().add(middleware).build());
build_router(
chain,
pipelines,
|route| { route.get("/").to(get_handler); },
)
build_router(chain, pipelines, |route| {
route.get("/").to(get_handler);
})
}

/// Start a server and use a `Router` to dispatch requests
Expand Down Expand Up @@ -144,9 +139,8 @@ mod tests {
let body = response.read_body().unwrap();
let body_string = String::from_utf8(body).unwrap();
assert!(
body_string.starts_with(
"You have visited this page 1 time(s) before. Your last visit was ",
),
body_string
.starts_with("You have visited this page 1 time(s) before. Your last visit was ",),
"Wrong body: {}",
body_string
);
Expand Down
14 changes: 5 additions & 9 deletions examples/sessions/introduction/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ fn get_handler(mut state: State) -> (State, Response) {
&state,
StatusCode::Ok,
Some((
format!(
"You have visited this page {} time(s) before\n",
visits
).as_bytes()
format!("You have visited this page {} time(s) before\n", visits)
.as_bytes()
.to_vec(),
mime::TEXT_PLAIN,
)),
Expand Down Expand Up @@ -65,11 +63,9 @@ fn router() -> Router {
// connections. This should not be done in real applications.
.insecure();
let (chain, pipelines) = single_pipeline(new_pipeline().add(middleware).build());
build_router(
chain,
pipelines,
|route| { route.get("/").to(get_handler); },
)
build_router(chain, pipelines, |route| {
route.get("/").to(get_handler);
})
}

/// Start a server and use a `Router` to dispatch requests
Expand Down

0 comments on commit 5fd91f1

Please sign in to comment.