1 个稳定版本
1.0.0 | 2021年3月8日 |
---|
#58 in #twitter
4KB
whichever-compiles
宏 whichever_compiles!{}
将编译器分支,尝试不同的替代方案以找到可编译的一个。
https://twitter.com/m_ou_se/status/1368632701448818691
请勿使用此功能。
示例
use whichever_compiles::whichever_compiles;
fn main() {
whichever_compiles! {
try { thisfunctiondoesntexist(); }
try { invalid syntax 1 2 3 }
try { println!("missing arg: {}"); }
try { println!("hello {}", world()); }
try { 1 + 2 }
}
}
whichever_compiles! {
try { }
try { fn world() {} }
try { fn world() -> &'static str { "world" } }
}
$ cargo run
hello world
依赖项
~42KB