pub fn try_push(&self, item: T) -> Result<(), T> {
        match self.push_semaphore.try_acquire() {
            Ok(permit) => {
                self.queue.push(item).ok().unwrap();
                permit.forget();
                self.pop_semaphore.add_permits(1);
                Ok(())
            }
            Err(_) => Err(item),
        }
    }
/// Try to push an item into the queue. If the queue is full
/// the item is returned as `Err<T>`.
Try to push an item into the queue. If the queue is full
the item is returned as `Err`.
Try to push an item into the queue . If the queue is full the item is returned as ` Err ` .
pub fn try_push(&self, item: T) -> Result<(), T> {
        match self.push_semaphore.try_acquire() {
            Ok(permit) => {
                self.queue.push(item).ok().unwrap();
                permit.forget();
                self.pop_semaphore.add_permits(1);
                Ok(())
            }
            Err(_) => Err(item),
        }
    }
pub fn try_push ( & self , item : T ) -> Result < ( ) , T > { match self . push_semaphore . try_acquire ( ) { Ok ( permit ) => { self . queue . push ( item ) . ok ( ) . unwrap ( ) ; permit . forget ( ) ; self . pop_semaphore . add_permits ( 1 ) ; Ok ( ( ) ) } Err ( _ ) => Err ( item ) , } }
Try to push an item into the queue.
Try to push an item into the queue .
&self
item
T
&self
item
T