This repository was archived by the owner on Mar 4, 2025. It is now read-only.
File tree 3 files changed +10
-7
lines changed
3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 2
2
3
3
- Added the ` E: EntityEvent ` bound to ` EventlistenerPlugin<E> ` , to move compile errors from adding the plugin, to the event itself.
4
4
- Fixed a benchmark bug.
5
+ - Added helpful error message when ` EntityEvent ` derive macro fails to find ` #[target] ` .
5
6
6
7
# 0.8.0
7
8
Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " bevy_eventlistener_derive"
3
- version = " 0.8.0 "
3
+ version = " 0.8.1 "
4
4
edition = " 2021"
5
5
description = " Event listeners and callbacks for bevy"
6
6
license = " MIT OR Apache-2.0"
Original file line number Diff line number Diff line change @@ -29,12 +29,12 @@ pub fn derive(input: TokenStream) -> TokenStream {
29
29
// Get attributes #[..] on each field
30
30
for attr in field. attrs . iter ( ) {
31
31
// Parse the attribute
32
- match attr. meta {
33
- // Find the duplicated idents
34
- syn:: Meta :: Path ( ref path) if path. get_ident ( ) . unwrap ( ) == "target" => {
35
- target = Some ( field. ident . clone ( ) ) ;
32
+ if let syn:: Meta :: Path ( ref path) = attr. meta {
33
+ if let Some ( ident) = path. get_ident ( ) {
34
+ if ident == "target" {
35
+ target = Some ( field. ident . clone ( ) ) ;
36
+ }
36
37
}
37
- _ => ( ) ,
38
38
}
39
39
}
40
40
}
@@ -44,7 +44,9 @@ pub fn derive(input: TokenStream) -> TokenStream {
44
44
_ => panic ! ( "Must be a struct" ) ,
45
45
}
46
46
47
- let target = target. unwrap ( ) ;
47
+ let Some ( target) = target else {
48
+ panic ! ( "Missing `#[target] attribute. You must annotate the field with the target Entity, or instead manually implement EntityEvent." )
49
+ } ;
48
50
49
51
let gen = quote ! {
50
52
impl #impl_generics EntityEvent for #name #ty_generics #where_clause {
You can’t perform that action at this time.
0 commit comments