[−][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 oldT
or aVec<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 adefault-features=false
directive along with the dependency information in yourCargo.toml
Limitations
-
This approach does have some limitations you should be aware of.
More complex collections which don't use thestd::slice::
family of iterators aren't supported.
Currently, after the creation of a vector behind a Pluralize binding there is no way to grow that vector, it can only be modified using.pluralize_mut( )
which isn't capable of doing anything other than modifying preexisting elements.
Macros
impl_primitive_pluralize |
Traits
Pluralize | A trait implemented across both collections and single primitives which exposes an iterator |