File tree 1 file changed +12
-4
lines changed
crates/bevy_mod_scripting_core/src
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -138,10 +138,12 @@ impl<T: PartialReflect + ?Sized> PartialReflectExt for T {
138
138
139
139
fn as_option ( & self ) -> Result < Option < & dyn PartialReflect > , InteropError > {
140
140
if let bevy:: reflect:: ReflectRef :: Enum ( e) = self . reflect_ref ( ) {
141
- if let Some ( field) = e. field_at ( 0 ) {
142
- return Ok ( Some ( field) ) ;
143
- } else {
144
- return Ok ( None ) ;
141
+ if e. is_type ( Some ( "core" ) , "Option" ) {
142
+ if let Some ( field) = e. field_at ( 0 ) {
143
+ return Ok ( Some ( field) ) ;
144
+ } else {
145
+ return Ok ( None ) ;
146
+ }
145
147
}
146
148
}
147
149
@@ -535,7 +537,13 @@ mod test {
535
537
536
538
#[ test]
537
539
fn test_as_option_none ( ) {
540
+ #[ derive( Reflect ) ]
541
+ enum Test {
542
+ Unit ,
543
+ }
544
+
538
545
assert ! ( None :: <i32 >. as_option( ) . unwrap( ) . is_none( ) ) ;
546
+ assert ! ( Test :: Unit . as_option( ) . is_err( ) )
539
547
}
540
548
541
549
#[ test]
You can’t perform that action at this time.
0 commit comments