Expand description
This crate provides all the procedural macros that are used in the trait_based_collection
crate. These macros are used to generate the boilerplate code that is commonly required in the
implementation of a new Collection
.
This crate contains the following derivable macros:
This crate contains the following procedural macros:
Macros
This macro is used to generate the implementation of the
Iterator
, reference
IntoIterator
, and ExactSizeIterator
traits for a Collection
. This macro can be used
to avoid the boilerplate code that is required to implement these traits. This macro can
generate the implementation for both mutable and immutable references.Attribute Macros
This macro is used to check if the collection is expanded when it is full. This is used to
ensure that the collection is expanded when it is full. This macro should be used in the
implementation of the
add
method of the Collection
trait if the collection also implements
FixedSizeCollection
.This macro is used to check if the collection is expanded when it is full. This is used to
ensure that the collection is expanded when it is full. This macro should be used in the
implementation of the
add
method of the Collection
trait if the collection also implements
FixedSizeCollection
.A macro that duplicates a test for multiple data structures. This macros has the following
functionalities:
Derive Macros
This macro encapsulates all the Derive macros for a
Collection
. Currently it derives the
following traits:This macro is used to derive the
Default
a standard implementation for all the data
structures that implement the Collection
trait. The default implementation of the data
structure will use the new_default
method of the Collection
trait.This macro is used to derive the
Display
trait for all the data structures that implement
the Collection
trait. The Display
trait is implemented by iterating over the elements of
the data structure using iter
and printing them using the Display
trait of the type of the elements.This macro is used to derive the
Drop
trait for all the data structures that implement the
Collection
trait. The drop implementation will call the clear
method of the collection.
This will remove all the elements from the collection ensuring that the elements are also
dropped.This macro is used to derive the
Extend
trait for all the data structures that implement the
Collection
trait. The Extend
trait is implemented by iteratively adding the elements of
the iterator to the data structure using the add
method of the Collection
trait.This macro is used to derive the
FromIterator
a standard implementation for all the data
structures that implement the Collection
trait. This macro will automatically take into
account the size of the iterator and create a new instance of the data structure with the
appropriate capacity. This is useful for collections that have a fixed size (that implement the
FixedSizeCollection
trait) as it will prevent the collection from having to resize itself
multiple times.This macro is used to derive the
Index
and IndexMut
traits for all the data structures
that implement the Collection
trait. Both traits will use the get
and get_mut
methods of the collection to access the elements and will panic if the index is out of bounds.This macro is used to derive the
IntoIterator
a standard implementation for all the data
structures that implement the Collection
trait. This macro will create a generic wrapper
around the data structure and then use some of the Collection
methods to iterate over the
elements of the data structure.Generates a new macro for the
Collection
that follows the same syntax as array expressions.
The macro will be exported to the crate root and will be named the same as the collection
but in snake case.