Function galvanic_assert::matchers::collection::sorted_strictly_by_in_any_order [] [src]

pub fn sorted_strictly_by_in_any_order<'a, T, I, P>(
    predicate: P
) -> Box<Fn(&'a I) -> MatchResult> where
    &'a I: IntoIterator<Item = &'a T> + 'a,
    T: Ord + Debug + 'a,
    P: Fn(&'a T, &'a T) -> Ordering + 'static, 

Matches if the elements in the asserted collection are sorted strictly monotone according to the given predicate in any order.

The predicate is applied to all consecutive pairs of elements and returns the Ordering of the pair. The first Ordering different to Ordering::Equal defines the expected order of the collection. The ordering is allowed to be weakly monotone, i.e., equal elements are allowed to follow each other. An empty collection is assumed to be always sorted.

Examples

use galvanic_assert::matchers::collection::*;
assert_that!(&vec![5,4,3,2,1], sorted_strictly_by_in_any_order(|a: &i32, b: &i32| a.cmp(b)));
assert_that!(&vec![1,2,3,4,5], sorted_strictly_by_in_any_order(|a: &i32, b: &i32| a.cmp(b)));