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 ptr::from_ref and ptr::addr_eq in macro #13081

Conversation

BD103
Copy link
Member

@BD103 BD103 commented Apr 23, 2024

Objective

  • Clippy raises a few warnings on the latest nightly release. 📎

Solution

  • Use ptr::from_ref when possible, because it prevents you from accidentally changing the mutability as well as its type.
  • Use ptr::addr_eq when comparing two pointers, ignoring pointer metadata.

Both versions are equivalent (and likely compile the same). Both take advantage of early returns, known as "short-circuiting" when using the `&&` operator.

Fun fact: `&&` short circuiting is one of the reasons this operator is not overloadable.
@BD103 BD103 force-pushed the The-Office-Assistant-is-a-discontinued-intelligent-user-interface-for-Microsoft-Office branch from 810a7d7 to 500936b Compare April 23, 2024 22:54
@BD103 BD103 added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change labels Apr 23, 2024
@BD103 BD103 marked this pull request as ready for review April 23, 2024 22:54
@alice-i-cecile alice-i-cecile added this to the 0.14 milestone Apr 23, 2024
@james7132 james7132 added this pull request to the merge queue Apr 24, 2024
Merged via the queue into bevyengine:main with commit f1d1491 Apr 24, 2024
29 checks passed
@BD103 BD103 deleted the The-Office-Assistant-is-a-discontinued-intelligent-user-interface-for-Microsoft-Office branch April 24, 2024 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants