From 05ced584576f60a3d8f3565d15906ad872fdb979 Mon Sep 17 00:00:00 2001 From: Stiopa Koltsov Date: Fri, 6 Oct 2017 13:07:02 -0700 Subject: [PATCH] future.then() is identical to future.unit() Summary: Document that `future.then()` is identical to `future.unit()`. Put functions next to each other to make it clear, and use identical wording. Reviewed By: yfeldblum Differential Revision: D5955451 fbshipit-source-id: 1b55d5785dc0995d4d9364f48241e98ad01b31f4 --- folly/futures/Future.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/folly/futures/Future.h b/folly/futures/Future.h index 1c8faffd..5159062d 100644 --- a/folly/futures/Future.h +++ b/folly/futures/Future.h @@ -374,8 +374,16 @@ class Future : public SemiFuture { /// Convenience method for ignoring the value and creating a Future. /// Exceptions still propagate. + /// This function is identical to .unit(). Future then(); + /// Convenience method for ignoring the value and creating a Future. + /// Exceptions still propagate. + /// This function is identical to parameterless .then(). + Future unit() { + return then(); + } + /// Set an error callback for this Future. The callback should take a single /// argument of the type that you want to catch, and should return a value of /// the same type as this Future, or a Future of that type (see overload @@ -567,11 +575,6 @@ class Future : public SemiFuture { return then(x, std::forward(fn)); } - /// Discard a result, but propagate an exception. - Future unit() { - return then([]{ return Unit{}; }); - } - // Convert this Future to a SemiFuture to safely export from a library // without exposing a continuation interface SemiFuture semi() { -- 2.34.1