#meta #fundamental #general-purpose #collection #constructor #set #sample

no-std meta_tools_min

Collection of general purpose meta tools. Minimal Set.

3 releases

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

#2407 in Algorithms

Download history 261/week @ 2023-12-12 262/week @ 2023-12-19 101/week @ 2023-12-26 194/week @ 2024-01-02 205/week @ 2024-01-09 184/week @ 2024-01-16 159/week @ 2024-01-23 157/week @ 2024-01-30 189/week @ 2024-02-06 352/week @ 2024-02-13 401/week @ 2024-02-20 411/week @ 2024-02-27 436/week @ 2024-03-05 2928/week @ 2024-03-12 3351/week @ 2024-03-19 579/week @ 2024-03-26

7,363 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

~3.5MB
~89K SLoC