pub fn swap(&self, value: T) -> Result<Option<T>, SendError<T>> {
        let result;
        // Do this step first so that the cell is dropped when
        // `unpark` is called
        let task = {
            if let Some(ref cell) = self.inner.upgrade() {
                let mut inner = cell.borrow_mut();
                result = inner.value.take();
                inner.value = Some(value);
                inner.read_task.take()
            } else {
                return Err(SendError(value));
            }
        };
        if let Some(task) = task {
            task.notify();
        }
        return Ok(result);
    }
/// Sets the new new value of the stream and notifies the consumer if any.
///
/// This function will store the `value` provided as the current value for
/// this channel, replacing any previous value that may have been there. If
/// the receiver may still be able to receive this message, then `Ok` is
/// returned with the previous value that was in this channel.
///
/// If `Ok(Some)` is returned then this value overwrote a previous value,
/// and the value was never received by the receiver. If `Ok(None)` is
/// returned, then no previous value was found and the `value` is queued up
/// to be received by the receiver.
///
/// # Errors
///
/// This function will return an `Err` if the receiver has gone away and
/// it's impossible to send this value to the receiver. The error returned
/// retains ownership of the `value` provided and can be extracted, if
/// necessary.
Sets the new new value of the stream and notifies the consumer if any.
This function will store the `value` provided as the current value for
this channel, replacing any previous value that may have been there. If
the receiver may still be able to receive this message, then `Ok` is
returned with the previous value that was in this channel.

If `Ok(Some)` is returned then this value overwrote a previous value,
and the value was never received by the receiver. If `Ok(None)` is
returned, then no previous value was found and the `value` is queued up
to be received by the receiver.
Sets the new new value of the stream and notifies the consumer if any . This function will store the ` value ` provided as the current value for this channel replacing any previous value that may have been there . If the receiver may still be able to receive this message then ` Ok ` is returned with the previous value that was in this channel . If ` Ok ( Some ) ` is returned then this value overwrote a previous value and the value was never received by the receiver . If ` Ok ( None ) ` is returned then no previous value was found and the ` value ` is queued up to be received by the receiver .
pub fn swap(&self, value: T) -> Result<Option<T>, SendError<T>> {
        let result;
        // Do this step first so that the cell is dropped when
        // `unpark` is called
        let task = {
            if let Some(ref cell) = self.inner.upgrade() {
                let mut inner = cell.borrow_mut();
                result = inner.value.take();
                inner.value = Some(value);
                inner.read_task.take()
            } else {
                return Err(SendError(value));
            }
        };
        if let Some(task) = task {
            task.notify();
        }
        return Ok(result);
    }
pub fn swap ( & self , value : T ) -> Result < Option < T > , SendError < T > > { let result ; // Do this step first so that the cell is dropped when // `unpark` is called let task = { if let Some ( ref cell ) = self . inner . upgrade ( ) { let mut inner = cell . borrow_mut ( ) ; result = inner . value . take ( ) ; inner . value = Some ( value ) ; inner . read_task . take ( ) } else { return Err ( SendError ( value ) ) ; } } ; if let Some ( task ) = task { task . notify ( ) ; } return Ok ( result ) ; }
Sets the new new value of the stream and notifies the consumer if any.
Sets the new new value of the stream and notifies the consumer if any .
&self
value
T
&self
value
T
errors
This function will return an `Err` if the receiver has gone away and
it's impossible to send this value to the receiver. The error returned
retains ownership of the `value` provided and can be extracted, if
necessary.
This function will return an ` Err ` if the receiver has gone away and it ' s impossible to send this value to the receiver . The error returned retains ownership of the ` value ` provided and can be extracted if necessary .