use anyhow::{anyhow, Result}; pub fn v2a(v: Vec) -> Result<[T; N]> { <[T;N]>::try_from(v).map_err(|v: Vec| anyhow!("Expected a Vec of length {}, but got {}", N, v.len())) } pub fn concat(l: &[T], r: &[T]) -> Vec { let mut n = l.to_vec(); n.extend(r.iter().cloned()); return n; } pub fn unzip(zipped: Vec<(A, B)>) -> (Vec, Vec) { let mut va: Vec = Vec::with_capacity(zipped.len()); let mut vb: Vec = Vec::with_capacity(zipped.len()); for (a, b) in zipped.into_iter() { va.push(a); vb.push(b); } (va, vb) }