assert_matches:提供宏`assert_matches`来测试模式匹配

时间:2021-05-23 18:56:02
【文件属性】:
文件名称:assert_matches:提供宏`assert_matches`来测试模式匹配
文件大小:10KB
文件格式:ZIP
更新时间:2021-05-23 18:56:02
testing rust macros assert Rust assert_matches 提供一个assert_matches宏,它测试值是否与给定的模式匹配,如果匹配失败,则会引起恐慌。 #[macro_use] extern crate assert_matches; #[derive(Debug)] enum Foo { A ( i32 ), B ( i32 ), } let a = Foo :: A ( 1 ); assert_matches! (a, Foo :: A (_)); assert_matches! (a, Foo :: A (i) if i > 0 ); 要包含在您的项目中,仅当编译测试时,才将以下内容添加到您的Cargo.toml中: [ dev-dependencies ] assert_matches = " 1.5 " 并将以下内容添加到您的板条箱根目录中: #[cfg(test)] #[m
【文件预览】:
assert_matches-master
----.gitignore(18B)
----src()
--------lib.rs(11KB)
----Cargo.toml(428B)
----.github()
--------workflows()
----LICENSE-MIT(1KB)
----README.md(831B)
----tests()
--------selective_import2.rs(156B)
--------selective_import1.rs(144B)
----LICENSE-APACHE(11KB)

网友评论