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

add some #[must_use] to LockedAxes builder fns #506

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

RJ
Copy link
Sponsor Contributor

@RJ RJ commented Sep 3, 2024

Objective

  • Helps avoid my mistake of grabbing LockedAxes from a query and calling unlock_rotation() without reassigning to the component, failing to notice it returns self

Solution

  • Adds #[must_use] to builder-style fns that return Self, yielding this compiler warning:
warning: unused return value of `avian2d::prelude::LockedAxes::unlock_rotation` that must be used
  --> crates/avian2d/examples/uncommitted_example_fixed_joint_2d.rs:89:17
   |
89 |                 locked_axes.unlock_rotation();
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
   |
89 |                 let _ = locked_axes.unlock_rotation();
   |                 +++++++

@Jondolf Jondolf added A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on C-Usability A quality-of-life improvement that makes Avian easier to use labels Sep 4, 2024
@Jondolf Jondolf merged commit 2f83cc1 into Jondolf:main Sep 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on C-Usability A quality-of-life improvement that makes Avian easier to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants