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 crate::vec2::Vec2;
|
||||||
|
use num::{Num, ToPrimitive};
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Rect<T: Num + Copy> {
|
pub struct Rect<T: Num + Copy + ToPrimitive> {
|
||||||
pub pos: Vec2<T>,
|
pub pos: Vec2<T>,
|
||||||
pub size: 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> {
|
pub fn new(x: T, y: T, w: T, h: T) -> Rect<T> {
|
||||||
Rect {
|
Rect {
|
||||||
pos: Vec2 { x, y },
|
pos: Vec2 { x, y },
|
||||||
|
|
|
@ -6,7 +6,7 @@ pub struct Vec2<T: Num + Copy + ToPrimitive> {
|
||||||
pub y: T,
|
pub y: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Num + Copy> Vec2<T> {
|
impl<T: Num + Copy + ToPrimitive> Vec2<T> {
|
||||||
//pub static
|
//pub static
|
||||||
pub fn zero() -> Self {
|
pub fn zero() -> Self {
|
||||||
Vec2 {
|
Vec2 {
|
||||||
|
@ -17,11 +17,11 @@ impl<T: Num + Copy> Vec2<T> {
|
||||||
|
|
||||||
//pub
|
//pub
|
||||||
pub fn size(&self) -> usize {
|
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 {
|
fn default() -> Self {
|
||||||
Vec2 {
|
Vec2 {
|
||||||
x: T::default(),
|
x: T::default(),
|
||||||
|
|
Loading…
Reference in New Issue