tuplities
Tuple utilities in Rust, fractioned across several crates to improve compile times. There is a main crate tuplities that re-exports traits from subcrates in its prelude module, so that the subcrates may be compiled in parallel cutting down on overall build times.
This library is #[no_std] compatible, making it suitable for embedded systems and other environments without the standard library.
[]
= "0.1"
The library provides several traits for working with tuples:
TupleClone: Provides atuple_clone()method to clone tuples. All elements must implementClone.TupleCopy: Provides atuple_copy()method to copy tuples. All elements must implementCopy.TupleDebug: Provides atuple_debug()method that returns a debug string representation of the tuple. All elements must implementDebug.TupleDefault: Provides atuple_default()method to create default instances of tuples. All elements must implementDefault.TupleHash: Provides atuple_hash<H: Hasher>()method to hash tuples with any hasher. All elements must implementHash.TupleSipHasher24: Provides atuple_sip_hash()method that returns a hash value using SipHasher24. All elements must implementHash.TuplePartialEq: Provides atuple_eq()method to compare tuples for partial equality. All elements must implementPartialEq.TupleEq: Provides atuple_eq()method to compare tuples for total equality. All elements must implementEq.TuplePartialOrd: Provides atuple_partial_cmp()method to compare tuples for partial ordering. All elements must implementPartialOrd.TupleOrd: Provides atuple_cmp()method to compare tuples for total ordering. All elements must implementOrd.TupleOption: Provides atranspose()method to transpose a tuple of options into an option of a tuple. All elements must beOption<T>.IntoTupleOption: Provides aninto_options()method to convert a tuple into a tuple of options.TupleRef: Provides atuple_ref()method to get references to each element in the tuple.TupleMut: Provides atuple_mut()method to get mutable references to each element in the tuple.TuplePopFront: Provides apop_front()method to remove and return the first element of the tuple along with the remaining elements as a new tuple.TuplePopBack: Provides apop_back()method to remove and return the last element of the tuple along with the remaining elements as a new tuple.TuplePushFront<T>: Provides apush_front(element)method to add an element to the front of the tuple, returning a new tuple.TuplePushBack<T>: Provides apush_back(element)method to add an element to the back of the tuple, returning a new tuple.TupleRemove<Idx>: Provides aremove()method to remove and return the element at the specified indextypenum'sIdxof the tuple along with the remaining elements as a new tuple.TupleInsert<Idx, T>: Provides aninsert()method to insert an element at the specified indextypenum'sIdxinto the tuple, returning the tuple with the element inserted.TupleLen: Provides the length of the tuple as a compile-timetypenum::Unsignedtype.TupleIndex<Idx>: Provides anindex()method to access the element at the specified indextypenum'sIdxof the tuple.TupleIndexMut<Idx>: Provides anindex_mut()method to access a mutable reference to the element at the specified indextypenum'sIdxof the tuple.
Features
The crate provides features to generate trait implementations for tuples up to different sizes: 8 (default), 16, 32, 48, 64, 96, or 128 elements. Use the size-XX features to enable larger tuple support.
[]
= { = "0.1", = ["size-32"] }
Architecture
The project is split into multiple crates for improved compile times:
tuplities/: Main crate that re-exports traits from subcratestuplities-{trait_name}/: Individual crates providing specific traitstuplities-derive/: Procedural macro crate that generates trait implementations
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contribution
Contributions are welcome! Please open issues or pull requests on the GitHub repository.