pub struct FactoryBuilder<F: Factory> { /* private fields */ }Expand description
Accumulates .state(...) overrides before .make()/.create()
actually builds a value - Laravel’s own factory builder, minus the
PHP-side magic (no $this->state(fn (array $attributes) => [...])
merge-by-array-key; a state here is a plain FnOnce-shaped closure
over the whole typed value, applied via Rust’s own struct-update
syntax: |p| NewPost { title: "x".into(), ..p }).
Implementations§
Source§impl<F: Factory> FactoryBuilder<F>
impl<F: Factory> FactoryBuilder<F>
pub fn new() -> Self
Sourcepub fn state(
self,
f: impl Fn(<F::Model as Model>::New) -> <F::Model as Model>::New + Send + Sync + 'static,
) -> Self
pub fn state( self, f: impl Fn(<F::Model as Model>::New) -> <F::Model as Model>::New + Send + Sync + 'static, ) -> Self
Queues an override applied, in call order, after F::definition.
Sourcepub fn make(&self) -> <F::Model as Model>::New
pub fn make(&self) -> <F::Model as Model>::New
Eloquent’s make() - builds one value without persisting it.
Sourcepub fn make_many(&self, n: usize) -> Vec<<F::Model as Model>::New>
pub fn make_many(&self, n: usize) -> Vec<<F::Model as Model>::New>
Eloquent’s make()->count($n).
Trait Implementations§
Auto Trait Implementations§
impl<F> !RefUnwindSafe for FactoryBuilder<F>
impl<F> !UnwindSafe for FactoryBuilder<F>
impl<F> Forget for FactoryBuilder<F>
impl<F> Freeze for FactoryBuilder<F>
impl<F> Move for FactoryBuilder<F>
impl<F> Send for FactoryBuilder<F>
impl<F> Sync for FactoryBuilder<F>
impl<F> Unpin for FactoryBuilder<F>
impl<F> UnsafeUnpin for FactoryBuilder<F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more