mahf/problems/
encoding.rs

1//! Solution encodings.
2
3use std::collections::btree_set::BTreeSet;
4
5use trait_set::trait_set;
6
7trait_set! {
8    /// Collection of traits required by every solution encoding.
9    pub trait AnyEncoding = Clone + PartialEq + Send;
10}
11
12/// Validates whether the provided permutation is valid, i.e. if the elements are unique.
13pub fn valid_permutation<T>(iter: T) -> bool
14where
15    T: IntoIterator,
16    T::Item: Eq + Ord,
17{
18    let mut uniq = BTreeSet::new();
19    iter.into_iter().all(move |x| uniq.insert(x))
20}