pub trait Factory<M>: Sized {
// Required method
fn definition() -> M;
// Provided method
fn make_many(count: usize) -> Vec<M> { ... }
}Expand description
A model factory. Generates randomized fake instances of M for tests/dev.
Mirrors Laravel’s Post::factory()->count(50)->create(). The definition()
method returns a single random instance; make_many() / create_many()
generate batches.
Required Methods§
Sourcefn definition() -> M
fn definition() -> M
Generate one random in-memory instance.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.