//! Helpers for common checks for the validity of data.
/// Validates a collection contains exactly one item when expected to.
pubtraitExactlyOne<T> {fnexactly_one(self)->Result<T, usize>;}impl<T>ExactlyOne<T>forVec<T>{/// Returns the one item contained in the vector if there is exactly one
/// item; returns an error if there is more than one item in the vector.
fnexactly_one(mutself)->Result<T, usize>{let v =self.pop().ok_or(0_usize)?;ifself.is_empty(){Ok(v)}else{Err(self.len()+1)}}}