Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more assert_{future,stream} functions #2020

Merged
merged 3 commits into from Sep 22, 2020

Commits on Jan 3, 2020

  1. Use more assert_{future,stream} functions

    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.
    stepancheg committed Jan 3, 2020
    Copy the full SHA
    9cc215e View commit details
    Browse the repository at this point in the history

Commits on Sep 22, 2020

  1. Copy the full SHA
    8f828b2 View commit details
    Browse the repository at this point in the history
  2. fix imports

    taiki-e committed Sep 22, 2020
    Copy the full SHA
    2f996cd View commit details
    Browse the repository at this point in the history