Skip to content

Commit d7a6619

Browse files
authored
Add Vector2D.to_isize() and Vector3D.to_isize() (#535) (#536)
1 parent cd6fe97 commit d7a6619

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/vector.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,16 @@ impl<T: NumCast + Copy, U> Vector2D<T, U> {
715715
self.cast()
716716
}
717717

718+
/// Cast into an `isize` vector, truncating decimals if any.
719+
///
720+
/// When casting from floating vector vectors, it is worth considering whether
721+
/// to `round()`, `ceil()` or `floor()` before the cast in order to obtain
722+
/// the desired conversion behavior.
723+
#[inline]
724+
pub fn to_isize(self) -> Vector2D<isize, U> {
725+
self.cast()
726+
}
727+
718728
/// Cast into an `u32` vector, truncating decimals if any.
719729
///
720730
/// When casting from floating vector vectors, it is worth considering whether
@@ -1640,6 +1650,16 @@ impl<T: NumCast + Copy, U> Vector3D<T, U> {
16401650
self.cast()
16411651
}
16421652

1653+
/// Cast into an `isize` vector, truncating decimals if any.
1654+
///
1655+
/// When casting from floating vector vectors, it is worth considering whether
1656+
/// to `round()`, `ceil()` or `floor()` before the cast in order to obtain
1657+
/// the desired conversion behavior.
1658+
#[inline]
1659+
pub fn to_isize(self) -> Vector3D<isize, U> {
1660+
self.cast()
1661+
}
1662+
16431663
/// Cast into an `u32` vector, truncating decimals if any.
16441664
///
16451665
/// When casting from floating vector vectors, it is worth considering whether

0 commit comments

Comments
 (0)