From a0e191b6c78505bb75d82645c65c71293e2c56d9 Mon Sep 17 00:00:00 2001 From: iiisak <41641715+iiisak@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:08:18 +0200 Subject: [PATCH] Add `Vector2D.to_isize()` and `Vector3D.to_isize()` (#535) --- 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