Skip to content

Commit 4a3c135

Browse files
committed
fix Cow<'static, str>
1 parent b18bfa5 commit 4a3c135

File tree

1 file changed

+6
-3
lines changed
  • crates/bevy_mod_scripting_bindings/src/conversions

1 file changed

+6
-3
lines changed

crates/bevy_mod_scripting_bindings/src/conversions/primitive.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use bevy_reflect::PartialReflect;
1515
/// Note: string ref types cannot be effectively converted into their static reference versions without leaking, so they are not supported here.
1616
pub fn convert(value: &dyn PartialReflect, target: TypeId) -> Option<Box<dyn PartialReflect>> {
1717
let primitive = Primitive::from(value);
18-
let out = primitive.convert(target);
19-
out
18+
primitive.convert(target)
2019
}
2120

2221
/// A coercion primitive used for intermediate normalizations.
@@ -268,11 +267,15 @@ impl<'a> From<&'a dyn PartialReflect> for Primitive<'a> {
268267
&& let Some(v) = v.try_downcast_ref::<f64>()
269268
{
270269
Primitive::F(*v)
270+
} else if t == TypeId::of::<Cow<'static, str>>()
271+
&& let Some(v) = v.try_downcast_ref::<Cow<'static, str>>()
272+
{
273+
Primitive::S(v.clone())
271274
} else if t == TypeId::of::<String>()
272275
&& let Some(v) = v.try_downcast_ref::<String>()
273276
{
274277
Primitive::S(Cow::Borrowed(v.as_str()))
275-
} else if t == TypeId::of::<String>()
278+
} else if t == TypeId::of::<&'static str>()
276279
&& let Some(v) = v.try_downcast_ref::<&'static str>()
277280
{
278281
Primitive::S(Cow::Borrowed(*v))

0 commit comments

Comments
 (0)