mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
better doc string for Either
This commit is contained in:
parent
6c709b33cc
commit
9ddf5a3550
@ -253,7 +253,7 @@ use actix_web::{Either, Error, HttpResponse, httpcodes};
|
||||
type RegisterResult = Either<HttpResponse, Box<Future<Item=HttpResponse, Error=Error>>>;
|
||||
|
||||
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 {
|
||||
@ -264,12 +264,12 @@ fn index(req: HttpRequest) -> RegisterResult {
|
||||
.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
|
||||
|
@ -46,8 +46,9 @@ pub trait Responder {
|
||||
///
|
||||
/// type RegisterResult = Either<HttpResponse, Box<Future<Item=HttpResponse, Error=Error>>>;
|
||||
///
|
||||
///
|
||||
/// 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)]
|
||||
|
Loading…
Reference in New Issue
Block a user