Crate fundamental_data_type
source · [−]Expand description
Fundamental data types and type constructors, like Single, Pair, Many.
Module :: fundamental_data_type
Fundamental data types and type constructors, like Single, Pair, Homopair, Many.
In Rust, you often need to wrap a given type into a new one. The role of the orphan rules in particular is basically to prevent you from implementing external traits for external types. To overcome the restriction developer usually wrap the external type into a tuple introducing a new type. Type constructor does exactly that and auto-implement traits From, Into, Deref and few more for the constructed type.
Besides type constructor for single element there are type constructors for pair
, homopair
and many
:
Single
to wrap single element.Pair
to wrap pair of distinct elements.HomoPair
to wrap pair of elements with the same type.Many
to wrapVec
of elements.
To add to your project
cargo add type_constructor
Try out from the repository
git clone https://github.com/Wandalen/wTools
cd wTools
cd sample/rust/type_constructor_trivial_sample
cargo run
Modules
Exposed namespace of the module.
Variadic constructor.
Type constructor of many.
Orphan namespace of the module.
Type constructor of pair.
Prelude to use essentials: use my_module::prelude::*
.
Protected namespace of the module.
Type constructor of single.
Generic traits.
Type constructors.
Macros
Type constructor of many.
Pair type constructor.
Type constructor of single.
Variadic constructor.
Type constructor to define tuple wrapping a given type.
Structs
Type constructor to wrap pair of the same type.
Type constructor to wrap a another type into a tuple.
Type constructor to wrap two types into a tuple.
Type constructor to wrap a another type into a tuple.
Traits
Reinterpret as array.
Reinterpret as slice.
Reinterpret as tuple.
Clone as array.
Clone as tuple.
Constructor without arguments.
Constructor with single argument.
Constructor with two arguments.
Constructor with three arguments.