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 Vector2D.to_isize() and Vector3D.to_isize() (closes #535) #536

Merged
merged 1 commit into from
Sep 19, 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
20 changes: 20 additions & 0 deletions src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,16 @@ impl<T: NumCast + Copy, U> Vector2D<T, U> {
self.cast()
}

/// Cast into an `isize` vector, truncating decimals if any.
///
/// When casting from floating vector vectors, it is worth considering whether
/// to `round()`, `ceil()` or `floor()` before the cast in order to obtain
/// the desired conversion behavior.
#[inline]
pub fn to_isize(self) -> Vector2D<isize, U> {
self.cast()
}

/// Cast into an `u32` vector, truncating decimals if any.
///
/// When casting from floating vector vectors, it is worth considering whether
Expand Down Expand Up @@ -1640,6 +1650,16 @@ impl<T: NumCast + Copy, U> Vector3D<T, U> {
self.cast()
}

/// Cast into an `isize` vector, truncating decimals if any.
///
/// When casting from floating vector vectors, it is worth considering whether
/// to `round()`, `ceil()` or `floor()` before the cast in order to obtain
/// the desired conversion behavior.
#[inline]
pub fn to_isize(self) -> Vector3D<isize, U> {
self.cast()
}

/// Cast into an `u32` vector, truncating decimals if any.
///
/// When casting from floating vector vectors, it is worth considering whether
Expand Down