1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 let _id
: &Mat2
<f64> = &Matrix
::identity(1.0);
16 pub trait Index
<Index
,Result
> { fn get(&self, Index) -> Result { panic!() }
}
17 pub trait Dimensional
<T
>: Index
<usize, T
> { }
19 pub struct Mat2
<T
> { x: T }
20 pub struct Vec2
<T
> { x: T }
22 impl<T
> Dimensional
<Vec2
<T
>> for Mat2
<T
> { }
23 impl<T
> Index
<usize, Vec2
<T
>> for Mat2
<T
> { }
25 impl<T
> Dimensional
<T
> for Vec2
<T
> { }
26 impl<T
> Index
<usize, T
> for Vec2
<T
> { }
28 pub trait Matrix
<T
,V
>: Dimensional
<V
> {
29 fn identity(t
:T
) -> Self;
32 impl<T
> Matrix
<T
, Vec2
<T
>> for Mat2
<T
> {
33 fn identity(t
:T
) -> Mat2
<T
> { Mat2{ x: t }
}