Skip to content

Commit 6fb3656

Browse files
Remove all warnings when running doc tests
Warning that had previously been buried by not supplying `--no-capture` to `cargo test` have been addressed here.
1 parent cbcc307 commit 6fb3656

File tree

4 files changed

+32
-30
lines changed

4 files changed

+32
-30
lines changed

src/handler/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ impl<T> NewHandlerService<T>
3838
/// # extern crate hyper;
3939
/// # extern crate borrow_bag;
4040
/// #
41-
/// # use gotham::handler::{NewHandlerService, NewHandler, Handler};
41+
/// # use gotham::handler::NewHandlerService;
4242
/// # use gotham::state::State;
4343
/// # use hyper::server::{Request, Response};
4444
/// # use hyper::StatusCode;
4545
/// #
4646
/// # fn main() {
47-
/// fn handler(state: State, request: Request) -> (State, Response) {
47+
/// fn handler(state: State, _req: Request) -> (State, Response) {
4848
/// (state, Response::new().with_status(StatusCode::Accepted))
4949
/// }
5050
///
@@ -59,7 +59,7 @@ impl<T> NewHandlerService<T>
5959
/// # extern crate hyper;
6060
/// # extern crate borrow_bag;
6161
/// #
62-
/// # use gotham::handler::{NewHandlerService, NewHandler, Handler};
62+
/// # use gotham::handler::NewHandlerService;
6363
/// # use gotham::state::State;
6464
/// # use gotham::router::Router;
6565
/// # use gotham::router::tree::Tree;
@@ -70,7 +70,7 @@ impl<T> NewHandlerService<T>
7070
/// # use hyper::{StatusCode, Method};
7171
/// #
7272
/// # fn main() {
73-
/// fn handler(state: State, request: Request) -> (State, Response) {
73+
/// fn handler(state: State, _req: Request) -> (State, Response) {
7474
/// (state, Response::new().with_status(StatusCode::Accepted))
7575
/// }
7676
///
@@ -225,11 +225,10 @@ impl IntoHandlerFuture for Box<HandlerFuture> {
225225
/// # use gotham::router::tree::Tree;
226226
/// # use gotham::router::request_matcher::MethodOnlyRequestMatcher;
227227
/// # use gotham::dispatch::Dispatcher;
228-
/// # use gotham::handler::{NewHandler, IntoResponse};
229-
/// # use futures::{future, Future};
228+
/// # use gotham::handler::IntoResponse;
230229
/// # use hyper::Method;
231230
/// # use hyper::StatusCode;
232-
/// # use hyper::server::{Http, Request, Response};
231+
/// # use hyper::server::{Request, Response};
233232
/// #
234233
/// struct MyStruct {
235234
/// value: String
@@ -250,7 +249,7 @@ impl IntoHandlerFuture for Box<HandlerFuture> {
250249
/// }
251250
/// }
252251
///
253-
/// fn handler(state: State, req: Request) -> (State, MyStruct) {
252+
/// fn handler(state: State, _req: Request) -> (State, MyStruct) {
254253
/// (state, MyStruct::new())
255254
/// }
256255
///

src/middleware/mod.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ pub mod pipeline;
2121
/// # extern crate gotham;
2222
/// # extern crate hyper;
2323
/// #
24-
/// # use gotham::handler::{Handler, HandlerFuture};
24+
/// # use gotham::handler::HandlerFuture;
2525
/// # use gotham::middleware::Middleware;
2626
/// # use gotham::state::State;
27-
/// # use hyper::server::{Request, Response};
27+
/// # use hyper::server::Request;
2828
/// #
2929
/// struct NoopMiddleware;
3030
///
@@ -36,7 +36,9 @@ pub mod pipeline;
3636
/// }
3737
/// }
3838
/// #
39-
/// # fn main() {}
39+
/// # fn main() {
40+
/// # NoopMiddleware {};
41+
/// # }
4042
/// ```
4143
///
4244
/// Recording a piece of state data before passing the request through:
@@ -45,13 +47,14 @@ pub mod pipeline;
4547
/// # extern crate gotham;
4648
/// # extern crate hyper;
4749
/// #
48-
/// # use gotham::handler::{Handler, HandlerFuture};
50+
/// # use gotham::handler::HandlerFuture;
4951
/// # use gotham::middleware::Middleware;
5052
/// # use gotham::state::{State, StateData};
51-
/// # use hyper::server::{Request, Response};
53+
/// # use hyper::server::Request;
5254
/// #
5355
/// struct MiddlewareWithStateData;
5456
///
57+
/// # #[allow(unused)]
5558
/// struct MiddlewareStateData {
5659
/// i: i32,
5760
/// }
@@ -67,7 +70,9 @@ pub mod pipeline;
6770
/// }
6871
/// }
6972
/// #
70-
/// # fn main() {}
73+
/// # fn main() {
74+
/// # MiddlewareWithStateData {};
75+
/// # }
7176
/// ```
7277
///
7378
/// Terminating the request early based on some arbitrary condition:
@@ -77,9 +82,9 @@ pub mod pipeline;
7782
/// # extern crate hyper;
7883
/// # extern crate futures;
7984
/// #
80-
/// # use gotham::handler::{Handler, HandlerFuture};
85+
/// # use gotham::handler::HandlerFuture;
8186
/// # use gotham::middleware::Middleware;
82-
/// # use gotham::state::{State, StateData};
87+
/// # use gotham::state::{State};
8388
/// # use hyper::server::{Request, Response};
8489
/// # use hyper::{Method, StatusCode};
8590
/// # use futures::{future, Future};
@@ -99,7 +104,9 @@ pub mod pipeline;
99104
/// }
100105
/// }
101106
/// #
102-
/// # fn main() {}
107+
/// # fn main() {
108+
/// # ConditionalMiddleware {};
109+
/// # }
103110
/// ```
104111
///
105112
/// Asynchronous middleware, which continues the request after some action completes:
@@ -109,10 +116,10 @@ pub mod pipeline;
109116
/// # extern crate hyper;
110117
/// # extern crate futures;
111118
/// #
112-
/// # use gotham::handler::{Handler, HandlerFuture};
119+
/// # use gotham::handler::HandlerFuture;
113120
/// # use gotham::middleware::Middleware;
114121
/// # use gotham::state::State;
115-
/// # use hyper::server::{Request, Response};
122+
/// # use hyper::server::Request;
116123
/// # use futures::{future, Future};
117124
/// #
118125
/// struct AsyncMiddleware;
@@ -128,7 +135,9 @@ pub mod pipeline;
128135
/// }
129136
/// }
130137
/// #
131-
/// # fn main() {}
138+
/// # fn main() {
139+
/// AsyncMiddleware {};
140+
/// # }
132141
/// ```
133142
pub trait Middleware {
134143
/// Entry point to the middleware. To pass the request on to the application, the middleware

src/middleware/pipeline.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,10 @@ pub fn new_pipeline() -> PipelineBuilder<()> {
211211
/// #
212212
/// # use std::io;
213213
/// # use gotham::state::State;
214-
/// # use gotham::handler::{Handler, HandlerFuture};
214+
/// # use gotham::handler::HandlerFuture;
215215
/// # use gotham::middleware::{Middleware, NewMiddleware};
216-
/// # use gotham::middleware::pipeline::{new_pipeline, Pipeline, PipelineBuilder};
217-
/// # use hyper::server::{Request, Response};
218-
/// # use hyper::StatusCode;
216+
/// # use gotham::middleware::pipeline::new_pipeline;
217+
/// # use hyper::server::Request;
219218
/// #
220219
/// # #[derive(Clone)]
221220
/// # struct MiddlewareOne;
@@ -269,12 +268,8 @@ pub fn new_pipeline() -> PipelineBuilder<()> {
269268
/// # }
270269
/// # }
271270
/// #
272-
/// # fn handler(state: State, _: Request) -> (State, Response) {
273-
/// # (state, Response::new().with_status(StatusCode::Accepted))
274-
/// # }
275-
/// #
276271
/// # fn main() {
277-
/// let pipeline: Pipeline<_> = new_pipeline()
272+
/// new_pipeline()
278273
/// .add(MiddlewareOne)
279274
/// .add(MiddlewareTwo)
280275
/// .add(MiddlewareThree)

src/router/tree/node.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ mod tests {
429429
.segment(),
430430
"seg7");
431431

432-
println!("~~~");
433432
// GET /some/path/seg9/another/path
434433
assert_eq!(root.traverse(&["/", "some", "path", "seg9", "some2", "path2"])
435434
.unwrap()

0 commit comments

Comments
 (0)