Skip to content

OwningPtr should impl From<Box<T>> #13287

Open
@dmyyy

Description

@dmyyy

What problem does this solve or what need does it fill?

I am trying to copy the value for a type erased entity component of type &dyn Reflect.

insert_by_id requires an OwningPtr to be passed in. I want to copy the component &dyn Reflect points to and insert the same component for an entity. I can copy the value of &dyn Reflect via clone_value() giving me Box<dyn Reflect>.

There isn't an easy way to get an OwningPtr from a Box. A Box is a unique pointer to some value on the heap - I don't see any reason why it can't be an OwningPtr.

What solution would you like?

implement From<Box<T>> for OwningPtr.

What alternative(s) have you considered?

This can be done with raw pointers.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-PointersRelating to Bevy pointer abstractionsA-ReflectionRuntime information about typesC-FeatureA new feature, making something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesX-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions