[−][src]Crate pluralize
The Pluralize
trait exists to offer a single generic trait which can yield an iterator from any
reference. This allows generic code to be implemented where the plurality of the generic type is
flexible. This is accomplished by casting the reference of any single primitive into a single
element array of the same type and calling the appropriate .iter()
function.
In simplest terms if you specify that a generic type has the bounds Pluralize< T >
then that
type could be a plain old T
or a Vec<T>
. In order to make use of this simply call the
.puralize( )
method and iterate in a for loop.
Features
This crate is fully compatible with #![no_std]
projects, just include a
default-features=false
directive along with the dependency information in your Cargo.toml
Limitations
This approach does have some limitations you should be aware of.
More complex collections which don't use the std::slice::
family of iterators aren't supported.
Currently Adder/Taker constructs don't work with single items. Adding/Taking over primitives is a
planned feature over Option
Re-exports
pub use iter::Adder; |
pub use iter::AddController; |
Modules
iter |
Macros
impl_primitive_pluralize |
Traits
Pluralize | A trait implemented across both collections and single primitives which exposes an iterator |
PluralizeControlIter | A trait enabling further mutations to Pluralize<> objects through two Controller-Iterator objects |