Skip to main content

Factory

Trait Factory 

Source
pub trait Factory<T>: Send + Sync {
    // Required method
    fn build(&self) -> T;

    // Provided method
    fn build_batch(&self, count: usize) -> Vec<T> { ... }
}
Expand description

Factory trait for creating test data

Required Methods§

Source

fn build(&self) -> T

Build a single instance of the test data type.

Provided Methods§

Source

fn build_batch(&self, count: usize) -> Vec<T>

Build multiple instances of the test data type.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T, F> Factory<T> for FactoryBuilder<T, F>
where F: Fn() -> T + Send + Sync, T: Send + Sync,