std_tools

Crates.iostd_tools
lib.rsstd_tools
version0.1.4
sourcesrc
created_at2022-05-25 10:25:51.387915
updated_at2022-06-26 15:19:12.487686
descriptionCollection 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.
homepagehttps://github.com/Wandalen/wTools/tree/master/module/alias/std_tools
repositoryhttps://github.com/Wandalen/wTools/tree/master/module/alias/std_tools
max_upload_size
id593398
size942,758
Wandalen (Wandalen)

documentation

https://docs.rs/std_tools

README

Module :: std_tools

experimental rust-status docs.rs discord

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 std_tools::prelude::*;

fn main()
{
  println!( "implements!( 13_i32 => Copy ) : {}", implements!( 13_i32 => Copy ) );
  println!( "implements!( Box::new( 13_i32 ) => Copy ) : {}", implements!( Box::new( 13_i32 ) => Copy ) );
}

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 std_tools::prelude::*;

// types!
// {
//
//   single MySingle : f32;
//   single SingleWithParametrized : std::sync::Arc< T : Copy >;
//   single SingleWithParameter : < T >;
//
//   pair MyPair : f32;
//   pair PairWithParametrized : std::sync::Arc< T1 : Copy >, std::sync::Arc< T2 : Copy >;
//   pair PairWithParameter : < T1, T2 >;
//
//   pair MyHomoPair : f32;
//   pair HomoPairWithParametrized : std::sync::Arc< T : Copy >;
//   pair HomoPairWithParameter : < T >;
//
//   many MyMany : f32;
//   many ManyWithParametrized : std::sync::Arc< T : Copy >;
//   many ManyWithParameter : < T >;
//
// }
Commit count: 0

cargo fmt