#ring #circular #stack #array #no_std

no-std arraydeque

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

8 unstable releases (3 breaking)

0.4.2 Mar 3, 2018
0.4.1 Feb 19, 2018
0.3.1 Feb 16, 2018
0.2.3 Jun 2, 2017
0.1.3 Oct 31, 2016

#6 in No standard library

Download history 1913/week @ 2018-05-06 2639/week @ 2018-05-13 2885/week @ 2018-05-20 3825/week @ 2018-05-27 2337/week @ 2018-06-03 4051/week @ 2018-06-10 2837/week @ 2018-06-17 3295/week @ 2018-06-24 2657/week @ 2018-07-01 1756/week @ 2018-07-08 2360/week @ 2018-07-15 3890/week @ 2018-07-22 2606/week @ 2018-07-29

8,439 downloads per month

arraydeque

build status codecov 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.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)

MIT/Apache-2.0 license
  • No runtime deps

Reverse deps