future.then() is identical to future.unit()
authorStiopa Koltsov <nga@fb.com>
Fri, 6 Oct 2017 20:07:02 +0000 (13:07 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 6 Oct 2017 20:26:14 +0000 (13:26 -0700)
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

index 1c8faffdb7fddd8ffbecb44a41ef2291f66629d5..5159062db21454b7e60889bbb31b98f3a69e6794 100644 (file)
@@ -374,8 +374,16 @@ class Future : public SemiFuture<T> {
 
   /// Convenience method for ignoring the value and creating a Future<Unit>.
   /// Exceptions still propagate.
+  /// This function is identical to .unit().
   Future<Unit> then();
 
+  /// Convenience method for ignoring the value and creating a Future<Unit>.
+  /// Exceptions still propagate.
+  /// This function is identical to parameterless .then().
+  Future<Unit> 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<T> {
     return then(x, std::forward<Callback>(fn));
   }
 
-  /// Discard a result, but propagate an exception.
-  Future<Unit> unit() {
-    return then([]{ return Unit{}; });
-  }
-
   // Convert this Future to a SemiFuture to safely export from a library
   // without exposing a continuation interface
   SemiFuture<T> semi() {