Conversation
|
Note that this is technically a breaking change since it will break code calling I also wonder if we can improve the situation by e.g. adding a separate method to copy a |
Added a migration guide. |
|
Additionally, without |
|
Initial impressions on this are positive: I think this is a reasonable tradeoff. Needs a comment about the inconsistency though. |
Co-authored-by: Christian Hughes <9044780+ItsDoot@users.noreply.github.com>
|
@PPakalns, can you take a look at this quick? Is this pattern reasonable to use downstream in |
Objective
Trying to write a
bevy_immediatewidget with the following signature:Where it would be called like so (pseudocode):
However, this results in a compiler error as there's currently no way to split borrows on a
Ref<T>(there is noRef::clone).Solution
RefbothCloneandCopy, easily allowing split borrows.Note:
Res<T>is notCloneorCopyto make cloning theTout easier, but comparativelyRef<T>is much less commonly used (users primarily write&Tin their query). And even further, I believe the amount of users who both useRef<T>and who need to clone theTout will be quite small (we don't even have aRef::cloneinherent function, if that proves anything).Alternatively, we could add
Ref::cloneas an inherent function, but the UX on that isn't great.Testing
The rust compiler keeps us in check here.