[−][src]Crate tuplex
Rust tuple extension.
Features
-
adding/removing element at front/back
-
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
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 | Converts a tuple to another one, where the fields of the old tuple can be |
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 |
IntoVec | Converts a tuple into a |
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 |
PushFront | Adds a |
TupleOf | A tuple is composed of |
ValueOf | Marks that |