#tuple #tuple-split #tuple-join

tuplestructops

Structural manipulations for tuples

5 unstable releases

0.3.0 Jun 29, 2022
0.2.0 Jun 29, 2022
0.1.2 Jun 28, 2022
0.1.1 Jun 27, 2022
0.1.0 Jun 27, 2022

#45 in #tuple

Download history 126/week @ 2024-12-14 19/week @ 2024-12-21 20/week @ 2024-12-28 41/week @ 2025-01-04 60/week @ 2025-01-11 147/week @ 2025-01-18 222/week @ 2025-01-25 181/week @ 2025-02-01 134/week @ 2025-02-08 100/week @ 2025-02-15 119/week @ 2025-02-22 166/week @ 2025-03-01 191/week @ 2025-03-08 267/week @ 2025-03-15 255/week @ 2025-03-22 65/week @ 2025-03-29

821 downloads per month

MIT/Apache

10KB
137 lines

Structural operations for tuples

This crate implements splitting and joining tuples.

The traits are implemented for tuples from zero len (ie, () unit) to 16. (More with with the tuple_24 and tuple_32 features enabled.)

They are implemented for both tuples by value and reference, which either consume or borrow their inputs respectively.

An example of TupleJoin by value:

use tuplestructops::TupleJoin;

let out = (1,'a',"b").join((1., 2.));
println!("out {out:?}");

TupleSplit does the converse. It relies on pattern matching to determine the split.

use tuplestructops::TupleSplit;

let out: (_, (_,_,_)) = (1,2,3,4,5).split();
println!("out {out:?}");

Structural operations for Tuples

This crate implements three operations for tuples:

  • join
  • split
  • index

For example, you can simply concatenate two tuples with:

use tuplestructops::TupleJoin;

let concat = (1, 'b', 3).join(('a', 5, 'c'));

This crate focuses purely on the overall structure of tuples, and is completely agnostic to the types of their elements.

The implementations are O(N^2) in the number of tuple elements. By default they're implemented for up to 16 elements, but the additional

  • tuple_24
  • tuple_32

features allow the traits to be implemented for more elements.

The impl_docs feature enables documentation of the trait implementations for all the tuple types. It is disabled by default since it's very repetitive.

Dependencies