#ring #circular #stack #deque #array

no-std arraydeque

A ring buffer with a fixed capacity, which can be stored on the stack

11 releases

0.4.5 Mar 20, 2019
0.4.4 Mar 6, 2019
0.4.3 Aug 28, 2018
0.4.2 Mar 3, 2018
0.1.3 Oct 31, 2016

#8 in No standard library

Download history 2404/week @ 2018-12-20 43524/week @ 2018-12-27 3493/week @ 2019-01-03 3231/week @ 2019-01-10 2665/week @ 2019-01-17 2586/week @ 2019-01-24 2768/week @ 2019-01-31 2706/week @ 2019-02-07 1449/week @ 2019-02-14 2352/week @ 2019-02-21 2174/week @ 2019-02-28 2714/week @ 2019-03-07 2866/week @ 2019-03-14 2914/week @ 2019-03-21 3119/week @ 2019-03-28

11,318 downloads per month
Used in 8 crates (7 directly)

MIT/Apache

110KB
2K SLoC

arraydeque

build status crates.io docs.rs

A circular buffer with fixed capacity. Requires Rust 1.20+.

This crate is inspired by bluss/arrayvec

Documentation

Usage

First, add the following to your Cargo.toml:

[dependencies]
arraydeque = "0.4"

Next, add this to your crate root:

extern crate arraydeque;

Currently arraydeque by default links to the standard library, but if you would instead like to use arraydeque in a #![no_std] situation or crate you can request this via:

[dependencies]
arraydeque = { version = "0.4", default-features = false }

Example

extern crate arraydeque;

use arraydeque::ArrayDeque;

fn main() {
    let mut deque: ArrayDeque<[_; 2]> = ArrayDeque::new();
    assert_eq!(deque.capacity(), 2);
    assert_eq!(deque.len(), 0);

    deque.push_back(1);
    deque.push_back(2);
    assert_eq!(deque.len(), 2);

    assert_eq!(deque.pop_front(), Some(1));
    assert_eq!(deque.pop_front(), Some(2));
    assert_eq!(deque.pop_front(), None);
}

Changelog

  • 0.4.5 Update generic-array to 0.12.

  • 0.4.4 Fix UB: Some(ArrayDeque::new(xs)).is_some() == false. (#12)

  • 0.4.3 Add support for generic-array under use_generic_array feature.

  • 0.4.1 Capacity now equal to backend_array.len().

  • 0.3.1 Add behaviors: Saturating and Wrapping.

Contribution

All kinds of contribution are welcomed.

  • Issus. Feel free to open an issue when you find typos, bugs, or have any question.
  • Pull requests. New collection, better implementation, more tests, more documents and typo fixes are all welcomed.

License

Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

Dependencies

~32KB

  • build build.rs