pub fn dequeue(&mut self) -> Option<T> {
        match self.try_dequeue() {
            DequeueResult::Data(value) => Some(value),
            DequeueResult::Empty => None,
            DequeueResult::Limit(rest) => {
                thread::sleep(rest);

                if let DequeueResult::Data(value) = self.try_dequeue() {
                    Some(value)
                } else {
                    unreachable!()
                }
            }
        }
    }
/// Removes the first element and returns it, or `None` if the queue is empty.
///
/// Sleeps if the limit has been reached.
///
/// # Examples
///
/// ```
/// # use std::time::Duration;
/// use rate_limit_queue::RateLimitQueue;
///
/// let mut queue = RateLimitQueue::new(100, Duration::from_secs(1));
/// queue.enqueue(1);
/// queue.enqueue(2);
///
/// assert_eq!(queue.dequeue(), Some(1));
/// assert_eq!(queue.dequeue(), Some(2));
/// ```
Removes the first element and returns it, or `None` if the queue is empty.
Sleeps if the limit has been reached.
Removes the first element and returns it or ` None ` if the queue is empty . Sleeps if the limit has been reached .
pub fn dequeue(&mut self) -> Option<T> {
        match self.try_dequeue() {
            DequeueResult::Data(value) => Some(value),
            DequeueResult::Empty => None,
            DequeueResult::Limit(rest) => {
                thread::sleep(rest);
                if let DequeueResult::Data(value) = self.try_dequeue() {
                    Some(value)
                } else {
                    unreachable!()
                }
            }
        }
    }
pub fn dequeue ( & mut self ) -> Option < T > { match self . try_dequeue ( ) { DequeueResult :: Data ( value ) => Some ( value ) , DequeueResult :: Empty => None , DequeueResult :: Limit ( rest ) => { thread :: sleep ( rest ) ; if let DequeueResult :: Data ( value ) = self . try_dequeue ( ) { Some ( value ) } else { unreachable ! ( ) } } } }
Removes the first element and returns it, or `None` if the queue is empty.
Removes the first element and returns it or ` None ` if the queue is empty .
&mut self
&mut self
examples
None
use std::time::duration;
use rate_limit_queue::RateLimitQueue.

let mut queue = RateLimitQueue::new(100, Duration::from_secs(1));
queue.enqueue(1);
queue.enqueue(2).


use rate_limit_queue :: RateLimitQueue . let mut queue = RateLimitQueue :: new ( 100 Duration :: from_secs ( 1 )) ; queue . enqueue ( 1 ) ; queue . enqueue ( 2 ) .