From d7a66195e2bd630b6d453ac7f1a4fdb0ea472555 Mon Sep 17 00:00:00 2001 From: Isak <41641715+iiisak@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:26:41 +0000 Subject: [PATCH] Add `Vector2D.to_isize()` and `Vector3D.to_isize()` (#535) (#536) --- src/vector.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/vector.rs b/src/vector.rs index 9ce9026..4d832c1 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -715,6 +715,16 @@ impl Vector2D { 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 { + self.cast() + } + /// Cast into an `u32` vector, truncating decimals if any. /// /// When casting from floating vector vectors, it is worth considering whether @@ -1640,6 +1650,16 @@ impl Vector3D { 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 { + self.cast() + } + /// Cast into an `u32` vector, truncating decimals if any. /// /// When casting from floating vector vectors, it is worth considering whether