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

Implement Clone on With combinator #2290

Merged

Commits on Dec 13, 2020

  1. Derive Clone on With combinator

    Consider the following use-case of mpsc channels. There are two
    categories of producers which produce items of two distinct types,
    later unified in one using `With` combinator:
    
    ```
    let (sender, receiver) = mspc::channel(100);
    
    let download_status = sender.clone().with(|item| {
        futures::future::ok(Status::Download(item))
    });
    
    let unpack_status = sender.clone().with(|item| {
        futures::future::ok(Status::Unpack(item))
    });
    ```
    
    It would be convenient for `With` combinator to implement `Clone`,
    since the underlying sink, `futures::channel::mpsc::Sender`,
    implements it.
    
    This change adds `#[derive(Clone)]` to `With` combinator
    akhramov committed Dec 13, 2020
    Configuration menu
    Copy the full SHA
    e09a7e4 View commit details
    Browse the repository at this point in the history
  2. Derive Clone on With combinator

    Address review comments
    
    This change
    
    * Implements `Clone` for `With` manually since we don't want to have
      `U: Clone, Item: Clone` bounds.
    * Adds a test case for `Clone` implementation.
    akhramov committed Dec 13, 2020
    Configuration menu
    Copy the full SHA
    192f8e3 View commit details
    Browse the repository at this point in the history