tuplities-remove 0.1.4

A trait for removing elements from tuples at compile-time indices
Documentation

tuplities

Documentation CI Security Audit License: MIT Downloads

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.

[dependencies]
tuplities = "0.1.4"

The library provides several traits for working with tuples:

Features

The crate provides optional features to enable specific traits. All features are enabled by default for convenience, but can be selectively disabled to reduce compile time and binary size.

Trait Features

The following features enable individual trait crates:

  • clone: Enables TupleClone trait
  • copy: Enables TupleCopy trait
  • debug: Enables TupleDebug trait
  • tuple-default: Enables TupleDefault trait
  • eq: Enables TupleEq trait
  • flatten-nest: Enables FlattenNestedTuple, NestTuple, NestedTupleIndex, NestedTupleIndexMut, NestedTupleTryFrom, NestedTupleTryInto, NestTupleMatrix, FlattenNestedTupleMatrix, NestedTupleOption, IntoNestedTupleOption, and NestedTupleOptionWith traits
  • from: Enables TupleFrom and TupleInto traits
  • hash: Enables TupleHash trait
  • mut: Enables TupleMut and TupleMutMap traits
  • option: Enables TupleOption and IntoTupleOption traits
  • ord: Enables TupleOrd trait
  • partial-eq: Enables TuplePartialEq trait
  • partial-ord: Enables TuplePartialOrd trait
  • remove: Enables TupleRemove trait
  • insert: Enables TupleInsert trait
  • len: Enables TupleLen, UnitTuple, SingletonTuple, and PairTuple traits
  • index: Enables TupleIndex, TupleIndexMut, FirstTupleIndex, and LastTupleIndex traits
  • pop-front: Enables TuplePopFront, TupleRefFront, and TupleMutFront traits
  • pop-back: Enables TuplePopBack, TupleRefBack, and TupleMutBack traits
  • push-front: Enables TuplePushFront trait
  • push-back: Enables TuplePushBack trait
  • ref: Enables TupleRef and TupleRefMap traits
  • replicate: Enables TupleReplicate trait
  • reverse: Enables TupleReverse trait
  • row: Enables TupleRow, TupleRowMut, FirstTupleRow, and LastTupleRow traits
  • split: Enables TupleSplit trait
  • try-from: Enables TupleTryFrom and TupleTryInto traits

Size Features

Additionally, 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.

[dependencies]
tuplities = { version = "0.1.4", default-features = false, features = ["clone", "index", "size-32"] }

Performance

Compile times scale with tuple size due to code generation. Below are measured build times for different maximum tuple sizes captured via the project's measure_compile_times.sh script on a typical development machine. Values are approximate and represent wall-clock real times. If you only plan to use variadic nested tuples, you may prefer to use only the tuplities-flatten-nest crate, which has significantly lower compile times.

tuplities (root crate)

Max Tuple Size Compile Time
8 (default) ~3.37s
16 ~2.71s
32 ~3.27s
48 ~4.55s
64 ~6.82s
96 ~15.60s
128 ~32.54s

tuplities-flatten-nest (flatten-nest crate only)

Max Tuple Size Compile Time
8 (default) ~3.34s
16 ~2.39s
32 ~2.43s
48 ~2.56s
64 ~2.77s
96 ~3.35s
128 ~4.52s

Architecture

The project is split into multiple crates for improved compile times:

  • tuplities/: Main crate that re-exports traits from subcrates
  • tuplities-{trait_name}/: Individual crates providing specific traits
  • tuplities-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.