diff --git a/src/app.rs b/src/app.rs index ae510621c..e9b10081b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -79,6 +79,27 @@ where /// multiple times. If you want to share state between different /// threads, a shared object should be used, e.g. `Arc`. Application /// state does not need to be `Send` or `Sync`. + /// + /// ```rust + /// use std::cell::Cell; + /// use actix_web::{web, State, App}; + /// + /// struct MyState { + /// counter: Cell, + /// } + /// + /// fn index(state: State) { + /// state.counter.set(state.counter.get() + 1); + /// } + /// + /// fn main() { + /// let app = App::new() + /// .state(MyState{ counter: Cell::new(0) }) + /// .resource( + /// "/index.html", + /// |r| r.route(web::get().to(index))); + /// } + /// ``` pub fn state(mut self, state: S) -> Self { self.state.push(Box::new(State::new(state))); self diff --git a/src/extractor.rs b/src/extractor.rs index 04dfb81ae..ea7681b0e 100644 --- a/src/extractor.rs +++ b/src/extractor.rs @@ -938,66 +938,21 @@ impl

FromRequest

for () { } } +#[rustfmt::skip] +mod m { + use super::*; + tuple_from_req!(TupleFromRequest1, (0, A)); tuple_from_req!(TupleFromRequest2, (0, A), (1, B)); tuple_from_req!(TupleFromRequest3, (0, A), (1, B), (2, C)); tuple_from_req!(TupleFromRequest4, (0, A), (1, B), (2, C), (3, D)); tuple_from_req!(TupleFromRequest5, (0, A), (1, B), (2, C), (3, D), (4, E)); -tuple_from_req!( - TupleFromRequest6, - (0, A), - (1, B), - (2, C), - (3, D), - (4, E), - (5, F) -); -tuple_from_req!( - TupleFromRequest7, - (0, A), - (1, B), - (2, C), - (3, D), - (4, E), - (5, F), - (6, G) -); -tuple_from_req!( - TupleFromRequest8, - (0, A), - (1, B), - (2, C), - (3, D), - (4, E), - (5, F), - (6, G), - (7, H) -); -tuple_from_req!( - TupleFromRequest9, - (0, A), - (1, B), - (2, C), - (3, D), - (4, E), - (5, F), - (6, G), - (7, H), - (8, I) -); -tuple_from_req!( - TupleFromRequest10, - (0, A), - (1, B), - (2, C), - (3, D), - (4, E), - (5, F), - (6, G), - (7, H), - (8, I), - (9, J) -); +tuple_from_req!(TupleFromRequest6, (0, A), (1, B), (2, C), (3, D), (4, E), (5, F)); +tuple_from_req!(TupleFromRequest7, (0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G)); +tuple_from_req!(TupleFromRequest8, (0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H)); +tuple_from_req!(TupleFromRequest9, (0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H), (8, I)); +tuple_from_req!(TupleFromRequest10, (0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H), (8, I), (9, J)); +} #[cfg(test)] mod tests {