9个不稳定版本 (4个破坏性更改)
0.5.2 | 2023年3月7日 |
---|---|
0.4.0 | 2022年11月13日 |
0.3.0 | 2022年4月15日 |
0.2.0 | 2022年1月19日 |
0.1.1 | 2021年4月9日 |
#685 in 过程宏
每月77次下载
19KB
bevycheck
Bevycheck通过添加过程宏帮助调试bevy错误,这些宏有助于编译器输出更好的编译错误。
如果您收到如下错误:the trait `IntoSystem<(), (), _>` is not implemented for fn item `for<'a> fn(bevy::prelude::ResMut<'a, [type error]>) {system}
,只需在您的函数中添加#[bevycheck::system]
,应该会显示更有帮助的错误信息。
#[bevycheck::system]
fn system(commands: &mut Commands, query: Query<(Entity, &GlobalTransform)>) {
// ...
}
它是如何工作的?
它通过替换
fn system(commands: &mut Commands, query: Query<(Entity, &GlobalTransform)>) {
// ...
}
为
fn system() {
assert_is_system_param::<&mut Commands>();
assert_is_system_param::<Query<(Entity, &GlobalTransform)>>();
panic!("remove bevycheck before running");
}
这样,没有参数的系统是有效的系统,并且调用 add_system
不会出错,通过断言每个特定参数必须是有效的系统参数,Rust可以确定是哪个参数有问题,并打印一个更有针对性的错误信息。
Bevy支持表
bevy | bevycheck |
---|---|
0.10 | 0.5 |
0.9 | 0.4 |
0.7 | 0.3 |
0.6 | 0.2 |
0.5 | 0.1 |
依赖关系
~1.5MB
~36K SLoC