ring-vec 0.1.1

A zero-dependency, no-std compatible, producer-consumer, fixed-size, item-oriented ring buffer backed by a vector.
Documentation
  • Coverage
  • 83.33%
    10 out of 12 items documented0 out of 11 items with examples
  • Size
  • Source code size: 23.33 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 861.59 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • irrustible/ring-vec
    7 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jjl

ring-vec

License Package Documentation

A zero-dependency, no-std compatible, producer-consumer, fixed-size, item-oriented ring buffer backed by a vector.

Requires alloc, for the vector.

Status

Brand new, with basic tests, seems to work.

Usage

    #[test]
    fn works() {
        let mut q: RingVec<usize> = RingVec::new(1);
        assert_eq!(q.peek(), None);
        assert_eq!(q.pop(), None);
        assert_eq!(q.push(1), Ok(()));
        assert_eq!(q.peek(), Some(&1));
        assert_eq!(q.pop(), Some(1));
        assert_eq!(q.peek(), None);
        assert_eq!(q.pop(), None);
        assert_eq!(q.push(2), Ok(()));
        assert_eq!(q.peek(), Some(&2));
        assert_eq!(q.push(3), Err(3));
        assert_eq!(q.pop(), Some(2));
        assert_eq!(q.push(4), Ok(()));
        assert_eq!(q.peek(), Some(&4));
        assert_eq!(q.pop(), Some(4));
        assert_eq!(q.peek(), None);
        assert_eq!(q.pop(), None);
        assert_eq!(q.peek(), None);
    }

Copyright and License

Copyright (c) 2020 James Laver, ring-vec contributors.

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.