# [−][src]Struct crossbeam::queue::SegQueue

    pub struct SegQueue<T> { /* fields omitted */ }

An unbounded multi-producer multi-consumer queue.

This queue is implemented as a linked list of segments, where each segment is a small buffer that can hold a handful of elements. There is no limit to how many elements can be in the queue at a time. However, since segments need to be dynamically allocated as elements get pushed, this queue is somewhat slower than `ArrayQueue`.

# Examples

    use crossbeam_queue::{PopError, SegQueue};

    let q = SegQueue::new();

    q.push('a');
    q.push('b');

    assert_eq!(q.pop(), Ok('a'));
    assert_eq!(q.pop(), Ok('b'));
    assert_eq!(q.pop(), Err(PopError));

## Methods

### `impl<T> SegQueue<T>`[src]

#### `pub fn new() -> SegQueue<T>`[src]

Creates a new unbounded queue.

# Examples

    use crossbeam_queue::SegQueue;

    let q = SegQueue::<i32>::new();

#### `pub fn push(&self, value: T)`[src]

Pushes an element into the queue.

# Examples

    use crossbeam_queue::SegQueue;

    let q = SegQueue::new();

    q.push(10);
    q.push(20);

#### `pub fn pop(&self) -> Result<T, PopError>`[src]

Pops an element from the queue.

If the queue is empty, an error is returned.

# Examples

    use crossbeam_queue::{PopError, SegQueue};

    let q = SegQueue::new();

    q.push(10);
    assert_eq!(q.pop(), Ok(10));
    assert_eq!(q.pop(), Err(PopError));

#### `pub fn is_empty(&self) -> bool`[src]

Returns `true` if the queue is empty.

# Examples

    use crossbeam_queue::SegQueue;

    let q = SegQueue::new();

    assert!(q.is_empty());
    q.push(1);
    assert!(!q.is_empty());

#### `pub fn len(&self) -> usize`[src]

Returns the number of elements in the queue.

# Examples

    use crossbeam_queue::{SegQueue, PopError};

    let q = SegQueue::new();
    assert_eq!(q.len(), 0);

    q.push(10);
    assert_eq!(q.len(), 1);

    q.push(20);
    assert_eq!(q.len(), 2);

## Trait Implementations

### `impl<T> Debug for SegQueue<T>`[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result<(), Error>`[src]

Formats the value using the given formatter. Read more

### `impl<T> Send for SegQueue<T> where
T: Send,` [src]

### `impl<T> Default for SegQueue<T>`[src]

#### `fn default() -> SegQueue<T>`[src]

Returns the "default value" for a type. Read more

### `impl<T> Sync for SegQueue<T> where
T: Send,` [src]

### `impl<T> Drop for SegQueue<T>`[src]

#### `fn drop(&mut self)`[src]

Executes the destructor for this type. Read more

## Auto Trait Implementations

### `impl<T> Unpin for SegQueue<T> where
T: Unpin,`

### `impl<T> !UnwindSafe for SegQueue<T>`

### `impl<T> RefUnwindSafe for SegQueue<T> where
T: RefUnwindSafe,`

## Blanket Implementations

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `fn into(self) -> U`[src]

Performs the conversion.

### `impl<T> From<T> for T`[src]

#### `fn from(t: T) -> T`[src]

Performs the conversion.

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

Performs the conversion.

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

####
ⓘImportant traits for &'_ mut W

### Important traits for &'_ mut W

`impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;`
`fn borrow_mut(&mut self) -> &mut T`[src]

Mutably borrows from an owned value. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

####
ⓘImportant traits for &'_ mut W

### Important traits for &'_ mut W

`impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;`
`fn borrow(&self) -> &T`[src]

Immutably borrows from an owned value. Read more

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `fn type_id(&self) -> TypeId`[src]

Gets the `TypeId` of `self`. Read more

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)