The function below, taken from here:
fn connection_for(
&self,
pool_key: PoolKey,
) -> impl Future<Output = Result<Pooled<PoolClient<B>>, ClientError<B>>> {
let checkout = self.pool.checkout(pool_key.clone());
let connect = self.connect_to(pool_key);
let executor = self.conn_builder.exec.clone();
// The order of the `select` is depended on below...
future::select(checkout, connect).then(move |either| match either {
...
should return a Future
. However, it returns the return result of
future::select(checkout, connect).then(...)
Where .then
does this:
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
Which is not a Future
. How it this possible?
I'm trying to understand what is returned by this function. This is the end of the '.then':
Either::Right((Err(err), checkout)) => Either::Right(Either::Right({
if err.is_canceled() {
Either::Left(checkout.map_err(ClientError::Normal))
} else {
Either::Right(future::err(ClientError::Normal(err)))
}
})),
It looks like it returns Either::Right(Either::Right
of something. I'm confused.