Pass Try by rvalue ref in onError implementation
[folly.git] / 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())); }));