27 releases (8 breaking)

0.9.0 Mar 16, 2024
0.7.0 Mar 16, 2024
0.5.0 Oct 28, 2023
0.2.18 Jul 18, 2022
0.1.0 Jan 10, 2022

#1768 in Development tools

Download history 313/week @ 2023-12-15 214/week @ 2023-12-22 125/week @ 2023-12-29 205/week @ 2024-01-05 280/week @ 2024-01-12 190/week @ 2024-01-19 178/week @ 2024-01-26 197/week @ 2024-02-02 250/week @ 2024-02-09 432/week @ 2024-02-16 454/week @ 2024-02-23 594/week @ 2024-03-01 1777/week @ 2024-03-08 4395/week @ 2024-03-15 1172/week @ 2024-03-22 1006/week @ 2024-03-29

8,455 downloads per month
Used in 81 crates (8 directly)

MIT license

62KB
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

~1.5–2MB
~40K SLoC