3 个版本
0.2.13 | 2022 年 7 月 18 日 |
---|---|
0.2.12 | 2022 年 7 月 15 日 |
0.2.11 | 2022 年 5 月 26 日 |
#25 in #constructor
1,233 下载/每月
在 7 个 crate 中使用 (通过 woptions_meta)
1MB
29K SLoC
模块 :: meta_tools
通用元工具集合。
示例 :: 集合的可变构造器
该模块除了其他有用的元工具外,还聚合了集合的可变构造器。例如,用于构造哈希表的宏 hmap!
。
#[ 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 );
}
示例 :: 函数式调用
对列表中的每个元素应用宏。
宏 for_each
可以以函数式方式或映射方式调用。将应用宏的名称作为第一个参数,并将宏名称后面的元素作为参数。使用逗号作为分隔符。
#[ cfg( feature = "for_each" ) ]
{
use meta_tools_min::*;
for_each!( dbg, "a", "b", "c" );
// generates
dbg!( "a" );
dbg!( "b" );
dbg!( "c" );
}
添加到您的项目
cargo add meta_tools
从仓库中尝试
git clone https://github.com/Wandalen/wTools
cd wTools
cd sample/rust/meta_tools_trivial
cargo run
依赖项
~3MB
~73K SLoC