Pass Try by rvalue ref in onError implementation
authorYedidya Feldblum <yfeldblum@fb.com>
Wed, 7 Jun 2017 21:39:54 +0000 (14:39 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 7 Jun 2017 21:50:33 +0000 (14:50 -0700)
Summary:
[Folly] Pass `Try` by rvalue ref in `onError` implementation.

As is done in other overloads and in `thenImplementation`. For consistency.

Reviewed By: spacedentist

Differential Revision: D5199302

fbshipit-source-id: c78db0c36fc7a0b846ca5e44fc237422c9203a24

folly/futures/Future-inl.h

index 79b73a07439267189f8131af34dae60c493d9014..2a8b56b888084e1b89175164d1430fab6ebfab75 100644 (file)
@@ -416,7 +416,7 @@ Future<T>::onError(F&& func) {
           if (tf2.hasException()) {
             state.setException(std::move(tf2.exception()));
           } else {
-            tf2->setCallback_([p = state.stealPromise()](Try<T> t3) mutable {
+            tf2->setCallback_([p = state.stealPromise()](Try<T> && t3) mutable {
               p.setTry(std::move(t3));
             });
           }
@@ -444,7 +444,7 @@ Future<T>::onError(F&& func) {
   auto f = p.getFuture();
   setCallback_(
       [state = detail::makeCoreCallbackState(
-           std::move(p), std::forward<F>(func))](Try<T> t) mutable {
+           std::move(p), std::forward<F>(func))](Try<T> && t) mutable {
         if (t.hasException()) {
           state.setTry(makeTryWith(
               [&] { return state.invoke(std::move(t.exception())); }));