diff --git a/guide/src/qs_4.md b/guide/src/qs_4.md index dd432d85a..be3d6cf33 100644 --- a/guide/src/qs_4.md +++ b/guide/src/qs_4.md @@ -253,23 +253,23 @@ use actix_web::{Either, Error, HttpResponse, httpcodes}; type RegisterResult = Either>>; fn index(req: HttpRequest) -> RegisterResult { - if true { // <- choose variant A + if is_a_variant() { // <- choose variant A Either::A( httpcodes::HttpBadRequest.with_body("Bad data")) } else { - Either::B( // <- variant B + Either::B( // <- variant B result(HttpResponse::Ok() .content_type("text/html") .body(format!("Hello!")) .map_err(|e| e.into())).responder()) } } - -fn main() { - Application::new() - .resource("/register", |r| r.f(index)) - .finish(); -} +# fn is_a_variant() -> bool { true } +# fn main() { +# Application::new() +# .resource("/register", |r| r.f(index)) +# .finish(); +# } ``` ## Tokio core handle diff --git a/src/handler.rs b/src/handler.rs index cd16e164c..498da39de 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -46,8 +46,9 @@ pub trait Responder { /// /// type RegisterResult = Either>>; /// +/// /// fn index(req: HttpRequest) -> RegisterResult { -/// if true { // <- choose variant A +/// if is_a_variant() { // <- choose variant A /// Either::A( /// httpcodes::HttpBadRequest.with_body("Bad data")) /// } else { @@ -58,6 +59,7 @@ pub trait Responder { /// .map_err(|e| e.into())).responder()) /// } /// } +/// # fn is_a_variant() -> bool { true } /// # fn main() {} /// ``` #[derive(Debug)]