#fundamental #general-purpose


Fundamental data types and type constructors, like Single, Pair, Many

7 releases

0.1.6 May 26, 2022
0.1.5 May 26, 2022

#238 in Algorithms

Download history 3/week @ 2022-12-04 3/week @ 2022-12-11 479/week @ 2022-12-18 317/week @ 2022-12-25 1/week @ 2023-01-01 157/week @ 2023-01-08 644/week @ 2023-01-15 357/week @ 2023-01-22 373/week @ 2023-01-29 539/week @ 2023-02-05 93/week @ 2023-02-12 912/week @ 2023-02-19 276/week @ 2023-02-26 123/week @ 2023-03-05 1091/week @ 2023-03-12 1620/week @ 2023-03-19

3,131 downloads per month

MIT license

25K SLoC

Module :: fundamental_data_type

experimental rust-status docs.rs discord

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 wrap Vec 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