Struct former::CollectionFormer
source · pub struct CollectionFormer<E, Definition>where
Definition: FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,{ /* private fields */ }
Expand description
A builder structure for constructing collections with a fluent and flexible interface.
Implementations§
source§impl<E, Definition> CollectionFormer<E, Definition>where
Definition: FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
impl<E, Definition> CollectionFormer<E, Definition>where
Definition: FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
sourcepub fn begin(
storage: Option<<Definition as FormerDefinition>::Storage>,
context: Option<<Definition as FormerDefinition>::Context>,
on_end: <Definition as FormerDefinition>::End,
) -> CollectionFormer<E, Definition>
pub fn begin( storage: Option<<Definition as FormerDefinition>::Storage>, context: Option<<Definition as FormerDefinition>::Context>, on_end: <Definition as FormerDefinition>::End, ) -> CollectionFormer<E, Definition>
Begins the construction process of a collection with optional initial storage and context,
setting up an on_end
completion handler to finalize the collection’s construction.
sourcepub fn begin_coercing<IntoEnd>(
storage: Option<<Definition as FormerDefinition>::Storage>,
context: Option<<Definition as FormerDefinition>::Context>,
on_end: IntoEnd,
) -> CollectionFormer<E, Definition>
pub fn begin_coercing<IntoEnd>( storage: Option<<Definition as FormerDefinition>::Storage>, context: Option<<Definition as FormerDefinition>::Context>, on_end: IntoEnd, ) -> CollectionFormer<E, Definition>
Provides a variation of the begin
method allowing for coercion of the end handler,
facilitating ease of integration with different end conditions.
sourcepub fn end(self) -> <Definition as FormerDefinition>::Formed
pub fn end(self) -> <Definition as FormerDefinition>::Formed
Finalizes the building process, returning the formed or a context incorporating it.
sourcepub fn form(self) -> <Definition as FormerDefinition>::Formed
pub fn form(self) -> <Definition as FormerDefinition>::Formed
Alias for the end
method to align with typical builder pattern terminologies.
sourcepub fn replace(
self,
storage: <Definition as FormerDefinition>::Storage,
) -> CollectionFormer<E, Definition>
pub fn replace( self, storage: <Definition as FormerDefinition>::Storage, ) -> CollectionFormer<E, Definition>
Replaces the current storage with a provided storage, allowing for resetting or redirection of the building process.
source§impl<E, Storage, Formed, Definition> CollectionFormer<E, Definition>where
Definition: FormerDefinition<Context = (), Storage = Storage, Formed = Formed>,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
impl<E, Storage, Formed, Definition> CollectionFormer<E, Definition>where
Definition: FormerDefinition<Context = (), Storage = Storage, Formed = Formed>,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
sourcepub fn new(
end: <Definition as FormerDefinition>::End,
) -> CollectionFormer<E, Definition>
pub fn new( end: <Definition as FormerDefinition>::End, ) -> CollectionFormer<E, Definition>
Constructs a new CollectionFormer
instance, starting with an empty storage.
This method serves as the entry point for the builder pattern, facilitating the
creation of a new collection.
sourcepub fn new_coercing<IntoEnd>(end: IntoEnd) -> CollectionFormer<E, Definition>
pub fn new_coercing<IntoEnd>(end: IntoEnd) -> CollectionFormer<E, Definition>
Variant of the new
method allowing for end condition coercion, providing flexibility
in specifying different types of end conditions dynamically.
source§impl<E, Definition> CollectionFormer<E, Definition>where
Definition: FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
impl<E, Definition> CollectionFormer<E, Definition>where
Definition: FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
sourcepub fn add<IntoElement>(
self,
entry: IntoElement,
) -> CollectionFormer<E, Definition>where
IntoElement: Into<E>,
pub fn add<IntoElement>(
self,
entry: IntoElement,
) -> CollectionFormer<E, Definition>where
IntoElement: Into<E>,
Appends an entry to the end of the storage, expanding the internal collection.
Trait Implementations§
source§impl<E, Definition> Debug for CollectionFormer<E, Definition>where
Definition: FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
impl<E, Definition> Debug for CollectionFormer<E, Definition>where
Definition: FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
source§impl<E, Definition> Default for CollectionFormer<E, Definition>where
E: Default,
Definition: Default + FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E> + Default,
<Definition as FormerDefinition>::Context: Default,
<Definition as FormerDefinition>::End: Default,
impl<E, Definition> Default for CollectionFormer<E, Definition>where
E: Default,
Definition: Default + FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E> + Default,
<Definition as FormerDefinition>::Context: Default,
<Definition as FormerDefinition>::End: Default,
source§fn default() -> CollectionFormer<E, Definition>
fn default() -> CollectionFormer<E, Definition>
source§impl<E, Definition> FormerBegin<Definition> for CollectionFormer<E, Definition>where
Definition: FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
impl<E, Definition> FormerBegin<Definition> for CollectionFormer<E, Definition>where
Definition: FormerDefinition,
<Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
source§fn former_begin(
storage: Option<<Definition as FormerDefinition>::Storage>,
context: Option<<Definition as FormerDefinition>::Context>,
on_end: <Definition as FormerDefinition>::End,
) -> CollectionFormer<E, Definition>
fn former_begin( storage: Option<<Definition as FormerDefinition>::Storage>, context: Option<<Definition as FormerDefinition>::Context>, on_end: <Definition as FormerDefinition>::End, ) -> CollectionFormer<E, Definition>
on_end
completion handler. Read moreAuto Trait Implementations§
impl<E, Definition> Freeze for CollectionFormer<E, Definition>where
<Definition as FormerDefinition>::Storage: Freeze,
<Definition as FormerDefinition>::Context: Freeze,
<Definition as FormerDefinition>::End: Freeze,
impl<E, Definition> RefUnwindSafe for CollectionFormer<E, Definition>where
<Definition as FormerDefinition>::Storage: RefUnwindSafe,
<Definition as FormerDefinition>::Context: RefUnwindSafe,
<Definition as FormerDefinition>::End: RefUnwindSafe,
impl<E, Definition> Send for CollectionFormer<E, Definition>where
<Definition as FormerDefinition>::Storage: Send,
<Definition as FormerDefinition>::Context: Send,
<Definition as FormerDefinition>::End: Send,
impl<E, Definition> Sync for CollectionFormer<E, Definition>where
<Definition as FormerDefinition>::Storage: Sync,
<Definition as FormerDefinition>::Context: Sync,
<Definition as FormerDefinition>::End: Sync,
impl<E, Definition> Unpin for CollectionFormer<E, Definition>where
<Definition as FormerDefinition>::Storage: Unpin,
<Definition as FormerDefinition>::Context: Unpin,
<Definition as FormerDefinition>::End: Unpin,
impl<E, Definition> UnwindSafe for CollectionFormer<E, Definition>where
<Definition as FormerDefinition>::Storage: UnwindSafe,
<Definition as FormerDefinition>::Context: UnwindSafe,
<Definition as FormerDefinition>::End: UnwindSafe,
Blanket Implementations§
source§impl<S> AssignWithType for S
impl<S> AssignWithType for S
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
source§impl<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
impl<C, E> EntryToVal<C> for Ewhere
C: Collection<Entry = E>,
source§type Val = <C as Collection>::Val
type Val = <C as Collection>::Val
Entry
in complex collections.
For example, in a HashMap
, while Entry
might be a ( key, value ) tuple, Val
might only be the value part.source§fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
fn entry_to_val(self) -> <E as EntryToVal<C>>::Val
source§impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
impl<C, Val> ValToEntry<C> for Valwhere
C: CollectionValToEntry<Val>,
source§fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry
Invokes the val_to_entry
function of the CollectionValToEntry
trait to convert the value to an entry.