1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Tiny ring-buffer types specialized for exactly two elements.
//!
//! This crate provides:
//! - [`RingPair`], storing values inline as `[T; 2]`
//! - [`BoxedRingPair`], storing values on the heap as `Box<[T; 2]>` (requires the `alloc` feature)
//!
//! # `no_std` support
//!
//! This crate is `no_std` compatible. [`RingPair`] is always available.
//! [`BoxedRingPair`] requires the `alloc` feature (enabled by default).
//!
//! # Examples
//! ```rust
//! use ring_pair::RingPair;
//!
//! let mut inline = RingPair::new(1);
//! inline.push(2);
//! assert_eq!(inline.as_pair(), (&1, &2));
//! ```
//!
//! ```rust
//! # #[cfg(feature = "alloc")]
//! use ring_pair::BoxedRingPair;
//!
//! # #[cfg(feature = "alloc")]
//! let mut boxed = BoxedRingPair::new(String::from("a"));
//! # #[cfg(feature = "alloc")]
//! boxed.push(String::from("b"));
//! # #[cfg(feature = "alloc")]
//! assert_eq!(boxed.as_pair(), (&String::from("a"), &String::from("b")));
//! ```
extern crate alloc;
pub use BoxedRingPair;
pub use Iter;
pub use RingPair;