下面的函数,取自这里:
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 {
...
应该返回一个Future
. 但是,它返回的返回结果
future::select(checkout, connect).then(...)
这是在哪里.then
:
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
哪个不是Future
. 这怎么可能?
我试图了解此函数返回的内容。这是'.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)))
}
})),
看起来它返回Either::Right(Either::Right
了一些东西。我很困惑。