Skip to content

Commit

Permalink
Add Vector2D.to_isize() and Vector3D.to_isize() (#535) (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
iiisak authored Sep 19, 2024
1 parent cd6fe97 commit d7a6619
Showing 1 changed file with 20 additions and 0 deletions.
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

0 comments on commit d7a6619

Please sign in to comment.