Repository: tokio-rs/tokio
File: tokio-stream/src/stream_map.rs (Rust)

Code before:
        Self::new()
    }
}

impl<K, V> StreamMap<K, V>
where
    K: Clone + Unpin,
    V: Stream + Unpin,
{
    /// Receives multiple items on this [`StreamMap`], extending the provided `buffer`.
    ///
    /// This method returns the number of items that is appended to the `buffer`.
    ///
    /// Note that this method does not guarantee that exactly `limit` items
    /// are received. Rather, if at least one item is available, it returns
    /// as many items as it can up to the given limit. This method returns
    /// zero only if the `StreamMap` is empty (or if `limit` is zero).
    ///
    /// # Cancel safety
    ///
    /// This method is cancel safe. If `next_many` is used as the event in a
    /// [`tokio::select!`] statement and some other branch completes first,
    /// it is guaranteed that no items were received on any of the underlying
    /// streams.
    ///
    /// [`tokio::select!`]: https://docs.rs/tokio/1.0/tokio/macro.select.html
    pub async fn next_many(&mut self, buffer: &mut Vec<(K, V::Item)>, limit: usize) -> usize {
        poll_fn(|cx| self.poll_next_many(cx, buffer, limit)).await
    }

    /// Polls to receive multiple items on this `StreamMap`, extending the provided `buffer`.
    ///
    /// This method returns:
    /// * `Poll::Pending` if no items are available but the `StreamMap` is not empty.
    /// * `Poll::Ready(count)` where `count` is the number of items successfully received and
    ///   stored in `buffer`. This can be less than, or equal to, `limit`.
    /// * `Poll::Ready(0)` if `limit` is set to zero or when the `StreamMap` is empty.
    ///
    /// Note that this method does not guarantee that exactly `limit` items
    /// are received. Rather, if at least one item is available, it returns
    /// as many items as it can up to the given limit. This method returns
    /// zero only if the `StreamMap` is empty (or if `limit` is zero).
    pub fn poll_next_many(
        &mut self,
        cx: &mut Context<'_>,
        buffer: &mut Vec<(K, V::Item)>,
        limit: usize,
    ) -> Poll<usize> {
        if limit == 0 || self.entries.is_empty() {
            return Poll::Ready(0);
        }

Review comment (suggestion):
```suggestion
    /// [`tokio::select!`]: https://docs.rs/tokio/latest/tokio/macro.select.html
```
Using `latest` will still work even when Tokio 2.x is released.

Using `1.0` has the benefit (?!) that it redirects to the latest released full version, e.g. `1.0.49` at the moment. Some people may find it a bit more user friendly.

Code after:
        Self::new()
    }
}

impl<K, V> StreamMap<K, V>
where
    K: Clone + Unpin,
    V: Stream + Unpin,
{
    /// Receives multiple items on this [`StreamMap`], extending the provided `buffer`.
    ///
    /// This method returns the number of items that is appended to the `buffer`.
    ///
    /// Note that this method does not guarantee that exactly `limit` items
    /// are received. Rather, if at least one item is available, it returns
    /// as many items as it can up to the given limit. This method returns
    /// zero only if the `StreamMap` is empty (or if `limit` is zero).
    ///
    /// # Cancel safety
    ///
    /// This method is cancel safe. If `next_many` is used as the event in a
    /// [`tokio::select!`] statement and some other branch completes first,
    /// it is guaranteed that no items were received on any of the underlying
    /// streams.
    ///
    /// [`tokio::select!`]: https://docs.rs/tokio/latest/tokio/macro.select.html
    pub async fn next_many(&mut self, buffer: &mut Vec<(K, V::Item)>, limit: usize) -> usize {
        poll_fn(|cx| self.poll_next_many(cx, buffer, limit)).await
    }

    /// Polls to receive multiple items on this `StreamMap`, extending the provided `buffer`.
    ///
    /// This method returns:
    /// * `Poll::Pending` if no items are available but the `StreamMap` is not empty.
    /// * `Poll::Ready(count)` where `count` is the number of items successfully received and
    ///   stored in `buffer`. This can be less than, or equal to, `limit`.
    /// * `Poll::Ready(0)` if `limit` is set to zero or when the `StreamMap` is empty.
    ///
    /// Note that this method does not guarantee that exactly `limit` items
    /// are received. Rather, if at least one item is available, it returns
    /// as many items as it can up to the given limit. This method returns
    /// zero only if the `StreamMap` is empty (or if `limit` is zero).
    pub fn poll_next_many(
        &mut self,
        cx: &mut Context<'_>,
        buffer: &mut Vec<(K, V::Item)>,
        limit: usize,
    ) -> Poll<usize> {
        if limit == 0 || self.entries.is_empty() {
            return Poll::Ready(0);
        }