Struct test_casing::TestCases

source ·
pub struct TestCases<T> { /* private fields */ }
Expand description

Container for test cases based on a lazily evaluated iterator. Should be constructed using the cases! macro.

§Examples

const NUMBER_CASES: TestCases<u32> = cases!([2, 3, 5, 8]);
const MORE_CASES: TestCases<u32> = cases! {
    NUMBER_CASES.into_iter().chain([42, 555])
};

// The `cases!` macro can wrap a statement block:
const COMPLEX_CASES: TestCases<u32> = cases!({
    use rand::{rngs::StdRng, Rng, SeedableRng};

    let mut rng = StdRng::seed_from_u64(123);
    (0..5).map(move |_| rng.gen())
});

Implementations§

source§

impl<T> TestCases<T>

source

pub const fn new(lazy: fn() -> Box<dyn Iterator<Item = T>>) -> Self

Creates a new set of test cases.

Trait Implementations§

source§

impl<T> Clone for TestCases<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for TestCases<T>

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> IntoIterator for TestCases<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = Box<dyn Iterator<Item = T>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> Copy for TestCases<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for TestCases<T>

§

impl<T> Send for TestCases<T>

§

impl<T> Sync for TestCases<T>

§

impl<T> Unpin for TestCases<T>

§

impl<T> UnwindSafe for TestCases<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.