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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/dynamics/rigid_body/locked_axes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,22 @@ impl LockedAxes {
}

/// Locks translation along the `X` axis.
#[must_use]
pub const fn lock_translation_x(mut self) -> Self {
self.0 |= 0b100_000;
self
}

/// Locks translation along the `Y` axis.
#[must_use]
pub const fn lock_translation_y(mut self) -> Self {
self.0 |= 0b010_000;
self
}

/// Locks translation along the `Z` axis.
#[cfg(feature = "3d")]
#[must_use]
pub const fn lock_translation_z(mut self) -> Self {
self.0 |= 0b001_000;
self
Expand All @@ -89,67 +92,77 @@ impl LockedAxes {

/// Locks rotation around the `Y` axis.
#[cfg(feature = "3d")]
#[must_use]
pub const fn lock_rotation_y(mut self) -> Self {
self.0 |= 0b000_010;
self
}

/// Locks rotation around the `Z` axis.
#[cfg(feature = "3d")]
#[must_use]
pub const fn lock_rotation_z(mut self) -> Self {
self.0 |= 0b000_001;
self
}

/// Locks all rotation.
#[cfg(feature = "2d")]
#[must_use]
pub const fn lock_rotation(mut self) -> Self {
self.0 |= 0b000_001;
self
}

/// Unlocks translation along the `X` axis.
#[must_use]
pub const fn unlock_translation_x(mut self) -> Self {
self.0 &= !0b100_000;
self
}

/// Unlocks translation along the `Y` axis.
#[must_use]
pub const fn unlock_translation_y(mut self) -> Self {
self.0 &= !0b010_000;
self
}

/// Unlocks translation along the `Z` axis.
#[cfg(feature = "3d")]
#[must_use]
pub const fn unlock_translation_z(mut self) -> Self {
self.0 &= !0b001_000;
self
}

/// Unlocks rotation around the `X` axis.
#[cfg(feature = "3d")]
#[must_use]
pub const fn unlock_rotation_x(mut self) -> Self {
self.0 &= !0b000_100;
self
}

/// Unlocks rotation around the `Y` axis.
#[cfg(feature = "3d")]
#[must_use]
pub const fn unlock_rotation_y(mut self) -> Self {
self.0 &= !0b000_010;
self
}

/// Unlocks rotation around the `Z` axis.
#[cfg(feature = "3d")]
#[must_use]
pub const fn unlock_rotation_z(mut self) -> Self {
self.0 &= !0b000_001;
self
}

/// Unlocks all rotation.
#[cfg(feature = "2d")]
#[must_use]
pub const fn unlock_rotation(mut self) -> Self {
self.0 &= !0b000_001;
self
Expand Down