tuple-traits 0.1.1

Additional tuple traits to enable ergonomic types.
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented3 out of 3 items with examples
  • Size
  • Source code size: 14.67 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.21 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • andogq/tuple-traits
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • andogq

Traits

Append

Append a type to a tuple.

static_assertions::assert_type_eq_all!(
    <(usize, char) as tuple_traits::Append>::Append<bool>,
    (usize, char, bool)
);

Cons

Represent a tuple as a cons (ish) value, with the first value on the left, and the rest of the tuple on the right.

static_assertions::assert_impl_all!(
    (usize, usize, usize): tuple_traits::Cons<Left = usize, Right = (usize, usize)>
);

Contains

A trait that will only be implement for a given target if it is present within a given type.

struct A;
struct B;
struct C;

fn requires_c<T, Index>(value: T)
where
    T: tuple_traits::Contains<C, Index>
{
}

// Works!
requires_c((A, B, C));

// Compiler error: `C` does not appear within `(A, B)`
// requires_c((A, B));

Example

Check out ./examples/buffer-flags.rs for a full example!