Repository: actix/actix-web
File: src/extractor.rs (Rust)

Code before:

/// Defines the result if neither or both of the extractors supplied to an Either<A,B> extractor succeed.
#[derive(Debug)]
pub enum EitherCollisionStrategy {
    /// If both are successful, return A, if both fail, return error of B
    PreferA,
    /// If both are successful, return B, if both fail, return error of A
    PreferB,
    /// Return result of the faster, error of the slower if both fail
    FastestSuccessful,

    /// Return error if both succeed, return error of A if both fail
    ErrorA,
    /// Return error if both succeed, return error of B if both fail
    ErrorB
}

impl Default for EitherCollisionStrategy {
    fn default() -> Self {
        EitherCollisionStrategy::FastestSuccessful
    }
}

///Determines Either extractor configuration
///
///By default uses default `EitherCollisionStrategy`
pub struct EitherConfig<A,B,S> where A: FromRequest<S>, B: FromRequest<S> {
    a: A::Config,
    b: B::Config,
    collision_strategy: EitherCollisionStrategy
}

impl<A,B,S> Default for EitherConfig<A,B,S> where A: FromRequest<S>, B: FromRequest<S> {
    fn default() -> Self {
        EitherConfig {
            a: A::Config::default(),
            b: B::Config::default(),
            collision_strategy: EitherCollisionStrategy::default()
        }
    }
}

/// Optionally extract a field from the request or extract the Error if unsuccessful
///
/// If the FromRequest for T fails, inject Err into handler rather than returning an error response
///
/// ## Example
///
/// ```rust
/// # extern crate actix_web;
/// extern crate rand;

Review comment (suggestion):
```suggestion
///By default uses default `EitherCollisionStrategy::FastestSuccessful`
```

Code after:

/// Defines the result if neither or both of the extractors supplied to an Either<A,B> extractor succeed.
#[derive(Debug)]
pub enum EitherCollisionStrategy {
    /// If both are successful, return A, if both fail, return error of B
    PreferA,
    /// If both are successful, return B, if both fail, return error of A
    PreferB,
    /// Return result of the faster, error of the slower if both fail
    FastestSuccessful,
    /// Return error if both succeed, return error of A if both fail
    ErrorA,
    /// Return error if both succeed, return error of B if both fail
    ErrorB
}

impl Default for EitherCollisionStrategy {
    fn default() -> Self {
        EitherCollisionStrategy::FastestSuccessful
    }
}

///Determines Either extractor configuration
///
///By default `EitherCollisionStrategy::FastestSuccessful` is used.
pub struct EitherConfig<A,B,S> where A: FromRequest<S>, B: FromRequest<S> {
    a: A::Config,
    b: B::Config,
    collision_strategy: EitherCollisionStrategy
}

impl<A,B,S> Default for EitherConfig<A,B,S> where A: FromRequest<S>, B: FromRequest<S> {
    fn default() -> Self {
        EitherConfig {
            a: A::Config::default(),
            b: B::Config::default(),
            collision_strategy: EitherCollisionStrategy::default()
        }
    }
}

/// Optionally extract a field from the request or extract the Error if unsuccessful
///
/// If the FromRequest for T fails, inject Err into handler rather than returning an error response
///
/// ## Example
///
/// ```rust
/// # extern crate actix_web;
/// extern crate rand;
/// #[macro_use] extern crate serde_derive;