made Vec2's T ToPrimitive
This commit is contained in:
parent
36c8b87d47
commit
ee2eb7c34d
|
@ -1,13 +1,13 @@
|
|||
use num::Num;
|
||||
use crate::vec2::Vec2;
|
||||
use num::{Num, ToPrimitive};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Rect<T: Num + Copy> {
|
||||
pub struct Rect<T: Num + Copy + ToPrimitive> {
|
||||
pub pos: Vec2<T>,
|
||||
pub size: Vec2<T>,
|
||||
}
|
||||
|
||||
impl<T: Num + Copy> Rect<T> {
|
||||
impl<T: Num + Copy + ToPrimitive> Rect<T> {
|
||||
pub fn new(x: T, y: T, w: T, h: T) -> Rect<T> {
|
||||
Rect {
|
||||
pos: Vec2 { x, y },
|
||||
|
|
|
@ -6,7 +6,7 @@ pub struct Vec2<T: Num + Copy + ToPrimitive> {
|
|||
pub y: T,
|
||||
}
|
||||
|
||||
impl<T: Num + Copy> Vec2<T> {
|
||||
impl<T: Num + Copy + ToPrimitive> Vec2<T> {
|
||||
//pub static
|
||||
pub fn zero() -> Self {
|
||||
Vec2 {
|
||||
|
@ -17,11 +17,11 @@ impl<T: Num + Copy> Vec2<T> {
|
|||
|
||||
//pub
|
||||
pub fn size(&self) -> usize {
|
||||
(self.x * self.y) as usize
|
||||
(self.x * self.y).to_usize().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Num + Copy + Default> Default for Vec2<T> {
|
||||
impl<T: Num + Copy + ToPrimitive + Default> Default for Vec2<T> {
|
||||
fn default() -> Self {
|
||||
Vec2 {
|
||||
x: T::default(),
|
||||
|
|
Loading…
Reference in New Issue