Crate meta_tools_min

Source
Expand description

Collection of general purpose meta tools. Minimal Set.

§Module :: meta_tools

experimental rust-status docs.rs discord

Collection of general purpose meta tools.

§Sample :: variadic constructor of collections

Among other useful meta tools the module aggregates variadtic constructors of collections. For example macro hmap! for constructing a hash map.

#[ cfg( feature = "collection_make" ) ]
{
  use meta_tools_min::*;

  let meta_map = hmap! { 3 => 13 };
  let mut std_map = std::collections::HashMap::new();
  std_map.insert( 3, 13 );
  assert_eq!( meta_map, std_map );
}

§Sample :: function-style call

Apply a macro for each element of a list.

Macro for_each may be called either in function-style way or in map-style way. Pass name of macro to apply to elements as the first arguments and elements after the macro name. Use comma as delimiter.

#[ cfg( feature = "for_each" ) ]
{
  use meta_tools_min::*;
  for_each!( dbg, "a", "b", "c" );

  // generates
  dbg!( "a" );
  dbg!( "b" );
  dbg!( "c" );
}

§To add to your project

cargo add meta_tools

§Try out from the repository

git clone https://github.com/Wandalen/wTools
cd wTools
cd sample/rust/meta_tools_trivial
cargo run

Modules§

dependency
Dependencies.
exposed
Exposed namespace of the module.
meta
Protocol of modularity unifying interface of a module and introducing layers.
meta_min
Collection of general purpose meta tools.
orphan
Orphan namespace of the module.
prelude
Prelude to use essentials: use my_module::prelude::*.
protected
Protected namespace of the module.
runtime
Protocol of modularity unifying interface of a module and introducing layers.

Macros§

_impls_callback
Internal impls1 macro. Don’t use.
bmap
Literally just a BTreeMap literal with keys and values into’d.
braces_unwrap
Unwrap braces of token tree and pass its content to the passed callback. If token tree in not braced then it passed to callback as is.
bset
Literally just a BTreeSet literal with values into’d.
fn_name
Get name of a function.
fn_rename
Macro to rename function.
fns
Split functions.
fns2
Split functions.
for_each
Module :: for_each
heap
Literally just a BinaryHeap literal with values into’d.
hmap
Literally just a HashMap literal with keys and values into’d.
hset
Literally just a HashSet literal with values into’d.
identity
Macro which returns its input as is.
idents_concat
impls
Define implementation putting each function under a macro.
impls1
Define implementation putting each function under a macro.
impls2
Define implementation putting each function under a macro.
impls3
Macros to put each function under a named macro to index every function in a class.
index
Index of items.
list
Literally just a LinkedList literal with values into’d.
mod_interface
Protocol of modularity unifying interface of a module and introducing layers.
tests_impls
Define implementation putting each function under a macro and adding attribute #[ test ].
tests_impls_optional
Define implementation putting each function under a macro and adding attribute #[ test ].
tests_index
Index of items.
vecd
Literally just a VecDeque literal with values into’d.