blunders_engine/arrayvec/
mod.rs

1//! Array Vector Types
2//!
3//! Eventually Blunders would like to use its own implementation for ArrayVec
4//! for experimental purposes but until they are stable arrayvec library is used.
5
6// mod arrayvec;
7// mod opt_arrayvec;
8
9// ArrayVec Implementation used in engine:
10pub use ::arrayvec::ArrayVec;
11
12use std::fmt::Display;
13
14/// Returns a string with the displayed string format of an ArrayVec.
15/// This is a temporary work-around until internal ArrayVec is stable,
16/// as Display cannot be implemented on external types.
17pub fn display<T: Display, const CAP: usize>(arrayvec: &ArrayVec<T, CAP>) -> String {
18    let mut displayed = String::new();
19    for item in arrayvec.iter() {
20        displayed.push_str(&item.to_string());
21        displayed.push(' ');
22    }
23    displayed.pop();
24
25    displayed
26}
27
28/// Appends all items of other to the ArrayVec.
29pub fn append<T, const CAP: usize>(vec: &mut ArrayVec<T, CAP>, other: ArrayVec<T, CAP>) {
30    for item in other {
31        vec.push(item);
32    }
33}