-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use more assert_{future,stream} functions (#2020)
Use `assert_future` and `assert_stream` annotations in almost all `FutureExt`, `TryFutureExt`, `StreamExt` and `TryStreamExt` trait fns. My own style of working with third-party code is doing Cmd-Click in Idea and look at signature/implementation. I found these existing `assert_` annotations very helpful in understanding what this particular function does, what it expects, what it returns, much faster than reading documentation or opening actual future/stream implementation. For example, there's `TryStreamExt::and_then` function: ``` fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F> where F: FnMut(Self::Ok) -> Fut, Fut: TryFuture<Error = Self::Error>, Self: Sized, { ... } ``` What does it do? Does it return a future or a stream? Is stream item original stream item or returned from future? Is error converted? Is it even `Try` object returned from this function? Now with the function body: ``` assert_stream::<Result<Fut::Ok, Fut::Error>, _>(...) ``` it's easier to infer that function returns a stream with the same items as provided future. So this diff extends `assert_` function to almost all functions of these four traits.
- Loading branch information
1 parent
fd1b938
commit 6541d01
Showing
6 changed files
with
101 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.