#error #debugging #bevy #error-message

bevycheck

通过过程宏提供有用的bevy错误信息

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 过程宏

Download history 25/week @ 2024-03-11 25/week @ 2024-03-18 8/week @ 2024-03-25 41/week @ 2024-04-01 18/week @ 2024-04-08 17/week @ 2024-04-15 24/week @ 2024-04-22 18/week @ 2024-04-29 16/week @ 2024-05-06 18/week @ 2024-05-13 29/week @ 2024-05-20 20/week @ 2024-05-27 16/week @ 2024-06-03 14/week @ 2024-06-10 21/week @ 2024-06-17 23/week @ 2024-06-24

每月77次下载

MIT许可

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