More explicit self.
This commit is contained in:
parent
c442cf148e
commit
fb59c90b88
6 changed files with 37 additions and 37 deletions
10
src/angle.rs
10
src/angle.rs
|
@ -70,8 +70,8 @@ pub impl<T:Copy Float> Radians<T>: Angle<T> {
|
|||
|
||||
pub impl<T:Copy Float> Radians<T>: Add<Radians<T>, Radians<T>> {
|
||||
#[inline(always)]
|
||||
pure fn add(rhs: &Radians<T>) -> Radians<T> {
|
||||
Radians(*self + **rhs)
|
||||
pure fn add(&self, rhs: &Radians<T>) -> Radians<T> {
|
||||
Radians(**self + **rhs)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,8 +164,8 @@ pub impl<T:Copy Float> Degrees<T>: Angle<T> {
|
|||
|
||||
pub impl<T:Copy Float> Degrees<T>: Add<Degrees<T>, Degrees<T>> {
|
||||
#[inline(always)]
|
||||
pure fn add(rhs: &Degrees<T>) -> Degrees<T> {
|
||||
Degrees(*self + **rhs)
|
||||
pure fn add(&self, rhs: &Degrees<T>) -> Degrees<T> {
|
||||
Degrees(**self + **rhs)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,4 +277,4 @@ pub struct Euler<T> {
|
|||
x: Radians<T>, // pitch
|
||||
y: Radians<T>, // yaw
|
||||
z: Radians<T>, // roll
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ pub impl<T> RGB<T>: Dimensional<T> {
|
|||
|
||||
pub impl<T:Copy> RGB<T>: Index<uint, T> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> T {
|
||||
pure fn index(&self, i: uint) -> T {
|
||||
unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[i] } }
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ pub impl<T:Copy> RGB<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*RGB<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ pub impl<T> RGBA<T>: Dimensional<T> {
|
|||
|
||||
pub impl<T:Copy> RGBA<T>: Index<uint, T> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> T {
|
||||
pure fn index(&self, i: uint) -> T {
|
||||
unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[i] } }
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ pub impl<T:Copy> RGBA<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*RGBA<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ pub impl<T> HSV<T>: Dimensional<T> {
|
|||
|
||||
pub impl<T:Copy> HSV<T>: Index<uint, T> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> T {
|
||||
pure fn index(&self, i: uint) -> T {
|
||||
unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[i] } }
|
||||
}
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ pub impl<T:Copy> HSV<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*HSV<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ pub impl<T> HSVA<T>: Dimensional<T> {
|
|||
|
||||
pub impl<T:Copy> HSVA<T>: Index<uint, T> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> T {
|
||||
pure fn index(&self, i: uint) -> T {
|
||||
unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[i] } }
|
||||
}
|
||||
}
|
||||
|
@ -727,7 +727,7 @@ pub impl<T:Copy> HSVA<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*HSVA<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -814,4 +814,4 @@ pub impl<T:Copy Float> HSVA<T>: Eq {
|
|||
pure fn ne(&self, other: &HSVA<T>) -> bool {
|
||||
!(self == other)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ pub impl f32: Approx {
|
|||
#[inline(always)] pure fn round(&self) -> f32 { f32::round(*self) }
|
||||
// #[inline(always)] pure fn roundEven(&self) -> f32 {}
|
||||
#[inline(always)] pure fn ceil(&self) -> f32 { f32::ceil(*self) }
|
||||
#[inline(always)] pure fn fract(&self) -> f32 { (*self) - floor(&*self) }
|
||||
#[inline(always)] pure fn fract(&self) -> f32 { (*self) - floor(self) }
|
||||
}
|
||||
|
||||
pub impl f64: Approx {
|
||||
|
@ -148,7 +148,7 @@ pub impl f64: Approx {
|
|||
#[inline(always)] pure fn round(&self) -> f64 { f64::round(*self) }
|
||||
// #[inline(always)] pure fn roundEven(&self) -> f64 {}
|
||||
#[inline(always)] pure fn ceil(&self) -> f64 { f64::ceil(*self) }
|
||||
#[inline(always)] pure fn fract(&self) -> f64 { (*self) - floor(&*self) }
|
||||
#[inline(always)] pure fn fract(&self) -> f64 { (*self) - floor(self) }
|
||||
}
|
||||
|
||||
pub impl float: Approx {
|
||||
|
@ -157,7 +157,7 @@ pub impl float: Approx {
|
|||
#[inline(always)] pure fn round(&self) -> float { f64::round(*self as f64) as float }
|
||||
// #[inline(always)] pure fn roundEven(&self) -> float {}
|
||||
#[inline(always)] pure fn ceil(&self) -> float { f64::ceil(*self as f64) as float }
|
||||
#[inline(always)] pure fn fract(&self) -> float { (*self) - floor(&*self) }
|
||||
#[inline(always)] pure fn fract(&self) -> float { (*self) - floor(self) }
|
||||
}
|
||||
|
||||
|
||||
|
@ -804,4 +804,4 @@ pub impl<T:Copy Mix> Vec4<T>: Mix {
|
|||
self[2].step(&edge[2]),
|
||||
self[3].step(&edge[3]))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
18
src/mat.rs
18
src/mat.rs
|
@ -608,10 +608,10 @@ pub impl<T:Copy> Mat2<T>: Dimensional<Vec2<T>> {
|
|||
|
||||
pub impl<T:Copy> Mat2<T>: Index<uint, Vec2<T>> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> Vec2<T> {
|
||||
pure fn index(&self, i: uint) -> Vec2<T> {
|
||||
unsafe { do buf_as_slice(
|
||||
transmute::<*Mat2<T>, *Vec2<T>>(
|
||||
to_unsafe_ptr(&self)), 2) |slice| { slice[i] }
|
||||
to_unsafe_ptr(self)), 2) |slice| { slice[i] }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ pub impl<T:Copy> Mat2<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*Mat2<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1105,10 +1105,10 @@ pub impl<T:Copy> Mat3<T>: Dimensional<Vec3<T>> {
|
|||
|
||||
pub impl<T:Copy> Mat3<T>: Index<uint, Vec3<T>> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> Vec3<T> {
|
||||
pure fn index(&self, i: uint) -> Vec3<T> {
|
||||
unsafe { do buf_as_slice(
|
||||
transmute::<*Mat3<T>, *Vec3<T>>(
|
||||
to_unsafe_ptr(&self)), 3) |slice| { slice[i] }
|
||||
to_unsafe_ptr(self)), 3) |slice| { slice[i] }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1118,7 +1118,7 @@ pub impl<T:Copy> Mat3<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*Mat3<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1679,10 +1679,10 @@ pub impl<T> Mat4<T>: Dimensional<Vec4<T>> {
|
|||
|
||||
pub impl<T:Copy> Mat4<T>: Index<uint, Vec4<T>> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> Vec4<T> {
|
||||
pure fn index(&self, i: uint) -> Vec4<T> {
|
||||
unsafe { do buf_as_slice(
|
||||
transmute::<*Mat4<T>, *Vec4<T>>(
|
||||
to_unsafe_ptr(&self)), 4) |slice| { slice[i] }
|
||||
to_unsafe_ptr(self)), 4) |slice| { slice[i] }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1692,7 +1692,7 @@ pub impl<T:Copy> Mat4<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*Mat4<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ pub impl<T> Quat<T>: Dimensional<T> {
|
|||
|
||||
pub impl<T:Copy> Quat<T>: Index<uint, T> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> T {
|
||||
pure fn index(&self, i: uint) -> T {
|
||||
unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[i] } }
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ pub impl<T:Copy> Quat<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*Quat<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -454,4 +454,4 @@ pub impl<T:Copy FuzzyEq> Quat<T>: FuzzyEq {
|
|||
self[2].fuzzy_eq(&other[2]) &&
|
||||
self[3].fuzzy_eq(&other[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
src/vec.rs
14
src/vec.rs
|
@ -314,7 +314,7 @@ pub impl<T> Vec2<T>: Dimensional<T> {
|
|||
|
||||
pub impl<T:Copy> Vec2<T>: Index<uint, T> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> T {
|
||||
pure fn index(&self, i: uint) -> T {
|
||||
unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[i] } }
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ pub impl<T:Copy> Vec2<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*Vec2<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ pub impl<T> Vec3<T>: Dimensional<T> {
|
|||
|
||||
pub impl<T:Copy> Vec3<T>: Index<uint, T> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> T {
|
||||
pure fn index(&self, i: uint) -> T {
|
||||
unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[i] } }
|
||||
}
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ pub impl<T:Copy> Vec3<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*Vec3<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -818,7 +818,7 @@ pub impl<T> Vec4<T>: Dimensional<T> {
|
|||
|
||||
pub impl<T:Copy> Vec4<T>: Index<uint, T> {
|
||||
#[inline(always)]
|
||||
pure fn index(i: uint) -> T {
|
||||
pure fn index(&self, i: uint) -> T {
|
||||
unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[i] } }
|
||||
}
|
||||
}
|
||||
|
@ -828,7 +828,7 @@ pub impl<T:Copy> Vec4<T>: ToPtr<T> {
|
|||
pure fn to_ptr(&self) -> *T {
|
||||
unsafe {
|
||||
transmute::<*Vec4<T>, *T>(
|
||||
to_unsafe_ptr(&*self)
|
||||
to_unsafe_ptr(self)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1037,4 +1037,4 @@ pub impl<T:Copy DefaultEq> Vec4<T>: DefaultEq {
|
|||
self[2].default_eq(&other[2]) &&
|
||||
self[3].default_eq(&other[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue