File tree 4 files changed +7
-6
lines changed
4 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -390,7 +390,7 @@ impl<'a> ReflectStruct<'a> {
390
390
let bevy_reflect_path = & self . meta ( ) . bevy_reflect_path ;
391
391
WhereClauseOptions {
392
392
active_types : self . active_types ( ) . into ( ) ,
393
- active_trait_bounds : quote ! { #bevy_reflect_path:: Reflect } ,
393
+ active_trait_bounds : quote ! { #bevy_reflect_path:: Reflect + #bevy_reflect_path :: GetTypeRegistration } ,
394
394
ignored_types : self . ignored_types ( ) . into ( ) ,
395
395
ignored_trait_bounds : quote ! { #FQAny + #FQSend + #FQSync } ,
396
396
}
@@ -468,7 +468,7 @@ impl<'a> ReflectEnum<'a> {
468
468
let bevy_reflect_path = & self . meta ( ) . bevy_reflect_path ;
469
469
WhereClauseOptions {
470
470
active_types : self . active_types ( ) . into ( ) ,
471
- active_trait_bounds : quote ! { #bevy_reflect_path:: FromReflect } ,
471
+ active_trait_bounds : quote ! { #bevy_reflect_path:: FromReflect + #bevy_reflect_path :: GetTypeRegistration } ,
472
472
ignored_types : self . ignored_types ( ) . into ( ) ,
473
473
ignored_trait_bounds : quote ! { #FQAny + #FQSend + #FQSync + #FQDefault } ,
474
474
}
Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ mod tests {
316
316
#[ test]
317
317
fn enum_should_allow_generics ( ) {
318
318
#[ derive( Reflect , Debug , PartialEq ) ]
319
- enum TestEnum < T : FromReflect + GetTypeRegistration > {
319
+ enum TestEnum < T : FromReflect > {
320
320
A ,
321
321
B ( T ) ,
322
322
C { value : T } ,
Original file line number Diff line number Diff line change @@ -1233,7 +1233,7 @@ mod tests {
1233
1233
1234
1234
// Struct (generic)
1235
1235
#[ derive( Reflect ) ]
1236
- struct MyGenericStruct < T : Reflect + GetTypeRegistration > {
1236
+ struct MyGenericStruct < T > {
1237
1237
foo : T ,
1238
1238
bar : usize ,
1239
1239
}
Original file line number Diff line number Diff line change 1
1
//! Demonstrates how reflection is used with generic Rust types.
2
2
3
3
use bevy:: prelude:: * ;
4
- use bevy:: reflect:: GetTypeRegistration ;
5
4
use std:: any:: TypeId ;
6
5
7
6
fn main ( ) {
@@ -13,8 +12,10 @@ fn main() {
13
12
. run ( ) ;
14
13
}
15
14
15
+ /// The `#[derive(Reflect)]` macro will automatically add any required bounds to `T`,
16
+ /// such as `Reflect` and `GetTypeRegistration`.
16
17
#[ derive( Reflect ) ]
17
- struct MyType < T : Reflect + GetTypeRegistration > {
18
+ struct MyType < T > {
18
19
value : T ,
19
20
}
20
21
You can’t perform that action at this time.
0 commit comments