Module :: non_std
Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind.
Sample :: implements
use *;
Sample :: type constructors
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.
Macro types is responsible for generating code for Single, Pair, Homopair, Many. Each type constructor has its own keyword for that, but Pair and Homopair use the same keyword difference in a number of constituent types. It is possible to define all types at once.
use *;
types!
Sample :: make - variadic constructor
Implement traits [Make0], [Make1] up to MakeN to provide the interface to construct your structure with a different set of arguments. In this example structure, Struct1 could be constructed either without arguments, with a single argument, or with two arguments.
- Constructor without arguments fills fields with zero.
- Constructor with a single argument sets both fields to the value of the argument.
- Constructor with 2 arguments set individual values of each field.
use *;
let got : Struct1 = make!;
let exp = Struct1;
assert_eq!;
let got : Struct1 = make!;
let exp = Struct1;
assert_eq!;
let got : Struct1 = make!;
let exp = Struct1;
assert_eq!;
To add to your project