pub fn chan<T>(cap: usize) -> (Sender<T>, Receiver<T>) {
    let channel = Arc::new(Channel::with_capacity(cap));
    let s = Sender {
        channel: channel.clone(),
        buffer: VecDeque::new(),
        listener: None,
    };
    let r = Receiver {
        channel,
        listener: None,
    };
    (s, r)
}
/// Creates a bounded multi-producer multi-consumer channel.
///
/// This channel has a buffer that can hold at most `cap` messages at a time.
///
/// Senders and receivers can be cloned. When all senders associated with a channel get dropped, it
/// becomes closed. Receive operations on a closed and empty channel return `None` instead of
/// trying to await a message.
///
/// # Panics
///
/// If `cap` is zero, this function will panic.
///
/// # Examples
///
/// ```
/// # async_std::task::block_on(async {
/// #
/// use std::time::Duration;
///
/// use async_std::sync::channel;
/// use async_std::task;
///
/// let (s, r) = channel(1);
///
/// // This call returns immediately because there is enough space in the channel.
/// s.send(1).await;
///
/// task::spawn(async move {
///     // This call will have to wait because the channel is full.
///     // It will be able to complete only after the first message is received.
///     s.send(2).await;
/// });
///
/// task::sleep(Duration::from_secs(1)).await;
/// assert_eq!(r.recv().await, Some(1));
/// assert_eq!(r.recv().await, Some(2));
/// #
/// # })
/// ```
Creates a bounded multi-producer multi-consumer channel.
This channel has a buffer that can hold at most `cap` messages at a time.

Senders and receivers can be cloned. When all senders associated with a channel get dropped, it
becomes closed. Receive operations on a closed and empty channel return `None` instead of
trying to await a message.
Creates a bounded multi - producer multi - consumer channel . This channel has a buffer that can hold at most ` cap ` messages at a time . Senders and receivers can be cloned . When all senders associated with a channel get dropped it becomes closed . Receive operations on a closed and empty channel return ` None ` instead of trying to await a message .
pub fn chan<T>(cap: usize) -> (Sender<T>, Receiver<T>) {
    let channel = Arc::new(Channel::with_capacity(cap));
    let s = Sender {
        channel: channel.clone(),
        buffer: VecDeque::new(),
        listener: None,
    };
    let r = Receiver {
        channel,
        listener: None,
    };
    (s, r)
}
pub fn chan < T > ( cap : usize ) -> ( Sender < T > , Receiver < T > ) { let channel = Arc :: new ( Channel :: with_capacity ( cap ) ) ; let s = Sender { channel : channel . clone ( ) , buffer : VecDeque :: new ( ) , listener : None , } ; let r = Receiver { channel , listener : None , } ; ( s , r ) }
Creates a bounded multi-producer multi-consumer channel.
Creates a bounded multi - producer multi - consumer channel .
cap
usize
panics
If `cap` is zero, this function will panic.
If ` cap ` is zero this function will panic .
examples
None
async_std::task::block_on(async {
use std::time::Duration.

use async_std::sync::channel;
use async_std::task.



This call returns immediately because there is enough space in the channel.

:spawn(async move {
This call will have to wait because the channel is full.
It will be able to complete only after the first message is received.

:sleep(Duration::from_secs(1)).await;
assert_eq!(r.recv().await, Some(1));
assert_eq!(r.recv().await, Some(2)).
use std :: time :: Duration . use async_std :: sync :: channel ; use async_std :: task . This call returns immediately because there is enough space in the channel . : spawn ( async move { This call will have to wait because the channel is full . It will be able to complete only after the first message is received . : sleep ( Duration :: from_secs ( 1 )) . await ; assert_eq! ( r . recv () . await Some ( 1 )) ; assert_eq! ( r . recv () . await Some ( 2 )) .
})
None