bevyengine / bevyengine/bevy

OwningPtr should impl From<Box<T>>

Open
#13,287 2 comments 0 reactions 0 assignees View on GitHub
A-Pointers A-Reflection C-Feature D-Modest X-Uncontroversial
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## 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`.

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>` for `OwningPtr`.

## What alternative(s) have you considered?

This can be done with raw pointers.

## Additional context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.