Skip to main content

SortAssertion

Trait SortAssertion 

Source
pub trait SortAssertion<T>
where T: PartialOrd,
{ // Required methods fn should_be_sorted_ascending(&self) -> &Self; fn should_be_sorted_descending(&self) -> &Self; }
Expand description

SortAssertion enables assertions about whether a collection’s elements are sorted in a specific order.

Required Methods§

Source

fn should_be_sorted_ascending(&self) -> &Self

  • Asserts that the elements of the collection are in ascending order (non-decreasing, allowing duplicates).
  • Returns a reference to self for fluent chaining.
  • Panics if the assertion fails.
§Example
use clearcheck::assertions::collection::sort::SortAssertion;

let collection = vec![1, 2, 3, 3, 5];
collection.should_be_sorted_ascending();
Source

fn should_be_sorted_descending(&self) -> &Self

  • Asserts that the elements of the collection are in descending order (non-increasing, allowing duplicates).
  • Returns a reference to self for fluent chaining.
  • Panics if the assertion fails.
§Example
use clearcheck::assertions::collection::sort::SortAssertion;

let collection = vec![5, 4, 3, 3, 2, 1];
collection.should_be_sorted_descending();

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, const N: usize> SortAssertion<T> for [T; N]
where T: Debug + PartialOrd,

Source§

impl<T> SortAssertion<T> for Vec<T>
where T: Debug + PartialOrd,

Source§

impl<T> SortAssertion<T> for [T]
where T: Debug + PartialOrd,

Implementors§