[][src]Crate tuplex

Rust tuple extension.

Features

  1. adding/removing element at front/back

  2. converting heterogeneous tuples to homogeneous ones

Examples: list operations

use tuplex::*;

let tuple = ();
assert_eq!( tuple.len(), 0 );

let tuple = tuple.push_front( 0 );
assert_eq!( tuple, (0,) );
assert_eq!( tuple.len(), 1 );

let tuple = tuple.push_front( false );
assert_eq!( tuple, (false,0) );
assert_eq!( tuple.len(), 2 );

let tuple = tuple.push_back( true );
assert_eq!( tuple, (false,0,true) );
assert_eq!( tuple.len(), 3 );

let tuple = tuple.push_back( 1 );
assert_eq!( tuple, (false,0,true,1) );
assert_eq!( tuple.len(), 4 );

let (front,tuple) = tuple.pop_front();
assert_eq!( front, false );
assert_eq!( tuple, (0,true,1) );

let (back,tuple) = tuple.pop_back();
assert_eq!( back, 1 );
assert_eq!( tuple, (0,true) );

Examples: homogeneous/heterogeneous conversions

use tuplex::*;

// `into_homo_tuple()` works because i32 can be converted from i3, u16 and i32.
assert_eq!( (3_i8, 7_u16, 21_i32).into_homo_tuple(), (3_i32, 7_i32, 21_i32) );

Macros

homo_tuple

Denotes a tuple type, the fields of which are of the same type. Up to 32 fields.

Structs

HTup0
HTup1
HTup2
HTup3
HTup4
HTup5
HTup6
HTup7
HTup8
HTup9
HTup10
HTup11
HTup12
HTup13
HTup14
HTup15
HTup16
HTup17
HTup18
HTup19
HTup20
HTup21
HTup22
HTup23
HTup24
HTup25
HTup26
HTup27
HTup28
HTup29
HTup30
HTup31
HTup32
HTupIter0
HTupIter1
HTupIter2
HTupIter3
HTupIter4
HTupIter5
HTupIter6
HTupIter7
HTupIter8
HTupIter9
HTupIter10
HTupIter11
HTupIter12
HTupIter13
HTupIter14
HTupIter15
HTupIter16
HTupIter17
HTupIter18
HTupIter19
HTupIter20
HTupIter21
HTupIter22
HTupIter23
HTupIter24
HTupIter25
HTupIter26
HTupIter27
HTupIter28
HTupIter29
HTupIter30
HTupIter31
HTupIter32

Traits

BinTuple

Reshape the linear tuple type to a binary tree, either left associated or right associated.

Convert

Converts to another type. The purpose of this trait is for implementing ConvertTuple.

ConvertTuple

Converts a tuple to another one, where the fields of the old tuple can be Convert-ed into the fiedls of the new tuple. See Convert.

FromTuple

Converts a tuple from another one, the fields of which can be converted into the fields of the new tuple.

HomoTuple

Homogeneous Tuple's trait.

IntoArray

Converts a tuple into an array, where the fields of the tuple can be converted into the same type of the array element.

IntoBoxedSlice

Converts a tuple into a boxed slice, where the fields of the tuple can be converted into the same type of the slice element.

IntoHomoTuple

Converts a heterogeneous tuple to a homogeneous one.

IntoTuple

Converts a tuple to a new one. This is the counterpart of FromTuple.

IntoVec

Converts a tuple into a Vec, where the fields of the tuple can be converted into the same type of the Vec's element.

Len

Indicate the amount of the tuple's fields.

MapHomoTuple

The map adapter for homogeneous tuples

PopBack

Removes the last field of the tuple.

PopFront

Removes the first field of the tuple.

PushBack

Adds a Back value to the tuple, as the last field.

PushFront

Adds a Front value to the tuple, as the first field.

TupleOf

A tuple is composed of T if all of its fields are values of T. See ValueOf.

ValueOf

Marks that Self is a value of T. The purpose of this trait is for implementing TupleOf.