3 releases

0.2.13 Jul 18, 2022
0.2.12 Jul 15, 2022
0.2.11 May 26, 2022

#2360 in Algorithms

Download history 318/week @ 2024-06-15 141/week @ 2024-06-22 361/week @ 2024-06-29 131/week @ 2024-07-06 398/week @ 2024-07-13 279/week @ 2024-07-20 318/week @ 2024-07-27 122/week @ 2024-08-03 290/week @ 2024-08-10 349/week @ 2024-08-17 694/week @ 2024-08-24 414/week @ 2024-08-31 385/week @ 2024-09-07 140/week @ 2024-09-14 125/week @ 2024-09-21 236/week @ 2024-09-28

914 downloads per month
Used in 7 crates (via woptions_meta)

MIT license

1MB
29K SLoC

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

Dependencies

~3MB
~73K SLoC