13 个版本
使用旧的 Rust 2015
| 0.3.9 | 2016年2月27日 | 
|---|---|
| 0.3.8 | 2016年1月16日 | 
| 0.3.6 | 2015年12月28日 | 
| 0.3.5 | 2015年11月28日 | 
| 0.1.0 | 2015年8月30日 | 
2507 在 Rust 模式 中
每月下载 31 次
21KB
446 行
power-assert-rs
Rust 中的 Power Assert。提供像这样的更好断言信息
$ cargo run --example normal
     Running `target/debug/examples/normal`
thread '<main>' panicked at 'assertion failed: bar.val == bar.foo.val
power_assert!(bar.val == bar.foo.val)
              |   |   |  |   |   |
              |   3   |  |   |   2
              |       |  |   Foo { val: 2 }
              |       |  Bar { val: 3, foo: Foo { val: 2 } }
              |       false
              Bar { val: 3, foo: Foo { val: 2 } }
', examples/normal.rs:26
An unknown error occurred
To learn more, run the command again with --verbose.
如何使用
将以下内容添加到您的 Cargo.toml
[dependencies]
power-assert = "*"
并将其添加到您的 lib.rs 或 main.rs
#![feature(plugin)]
#![plugin(power_assert)]
现在,您可以使用 power_assert!() 和 power_assert_eq!()。
如果您想覆盖内置的 assert!() 和 assert_eq!(),请按如下修改您的 lib.rs 或 main.rs。
#![feature(plugin)]
#![plugin(power_assert(override_builtins))]