fn do_something_random() -> impl Future<Item = (), Error = CustomError> {
    let mut rng = thread_rng();

    // 20% chance that () will be returned by this function
    if rng.gen_bool(2.0 / 10.0) {
        ok(())
    } else {
        err(rand::random::<CustomError>())
    }
}
/// randomly returns either () or one of the 4 CustomError variants
randomly returns either () or one of the 4 CustomError variants
randomly returns either () or one of the 4 CustomError variants
fn do_something_random() -> impl Future<Item = (), Error = CustomError> {
    let mut rng = thread_rng();
    // 20% chance that () will be returned by this function
    if rng.gen_bool(2.0 / 10.0) {
        ok(())
    } else {
        err(rand::random::<CustomError>())
    }
}
fn do_something_random ( ) -> impl Future < Item = ( ) , Error = CustomError > { let mut rng = thread_rng ( ) ; // 20% chance that () will be returned by this function if rng . gen_bool ( 2.0 / 10.0 ) { ok ( ( ) ) } else { err ( rand :: random :: < CustomError > ( ) ) } }
randomly returns either () or one of the 4 CustomError variants
randomly returns either () or one of the 4 CustomError variants