File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
crates/bevy_mod_scripting_core/src Expand file tree Collapse file tree 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 {
138138
139139 fn as_option ( & self ) -> Result < Option < & dyn PartialReflect > , InteropError > {
140140 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+ }
145147 }
146148 }
147149
@@ -535,7 +537,13 @@ mod test {
535537
536538 #[ test]
537539 fn test_as_option_none ( ) {
540+ #[ derive( Reflect ) ]
541+ enum Test {
542+ Unit ,
543+ }
544+
538545 assert ! ( None :: <i32 >. as_option( ) . unwrap( ) . is_none( ) ) ;
546+ assert ! ( Test :: Unit . as_option( ) . is_err( ) )
539547 }
540548
541549 #[ test]
You can’t perform that action at this time.
0 commit comments