30 releases (11 breaking)

0.12.0 Oct 30, 2024
0.10.0 May 11, 2024
0.9.0 Mar 16, 2024
0.5.0 Oct 28, 2023
0.1.0 Jan 10, 2022

#160 in Algorithms

Download history 378/week @ 2024-07-21 428/week @ 2024-07-28 183/week @ 2024-08-04 508/week @ 2024-08-11 337/week @ 2024-08-18 822/week @ 2024-08-25 502/week @ 2024-09-01 632/week @ 2024-09-08 360/week @ 2024-09-15 268/week @ 2024-09-22 358/week @ 2024-09-29 236/week @ 2024-10-06 284/week @ 2024-10-13 186/week @ 2024-10-20 519/week @ 2024-10-27 1038/week @ 2024-11-03

2,105 downloads per month
Used in 76 crates (9 directly)

MIT license

61KB
1K SLoC

Module :: meta_tools

experimental rust-status docs.rs Open in Gitpod discord

Collection of general purpose meta tools.

Basic use-case :: variadic constructor of collections

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

use meta_tools::*;

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 );

Basic Use Case :: 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.

use meta_tools::*;
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 examples/meta_tools_trivial
cargo run

Dependencies

~2.5MB
~47K SLoC