Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Cow<'static, str> in Name #1308

Merged
merged 4 commits into from
Feb 1, 2021
Merged

Use Cow<'static, str> in Name #1308

merged 4 commits into from
Feb 1, 2021

Conversation

CleanCut
Copy link
Member

When reading #1283 I thought to myself, "yay, a chance to try actually using Cow<...>!" ... and then found that Cow isn't Reflect yet...so I gave implementing that trait a shot too.

I cargo-culted more of this than I'm comfortable with, especially with the Reflect stuff, so please take a close look at this. I'm looking forward to learning what I did wrong. 😉 I originally tried to use impl_reflect_value!, but I couldn't untangle the 'static lifetime errors caused by it, so I went for the manual implementation.


fn apply(&mut self, value: &dyn Reflect) {
let value = value.any();
if let Some(value) = value.downcast_ref::<Self>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've removed type coercion from the reflect api (ex: we used to coerce all ints to the appropriate precision, but now we dont). I think for simplicity / consistency we should only accept Cow<'static, str> here unless absolutely necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Coercion removed.

@cart cart merged commit 0867dc7 into bevyengine:master Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants