On 04/16/2014 03:09 PM, Brendan Zabarauskas wrote:
For one, the Index trait is in dire need of an overhaul.
In respect to the operator traits in general, I have actually been thinking of
submitting an RFC proposing that they take thier parameters by-value instead of
by-ref. That would remove the auto-ref behaviour of the operators which is more
consistent with the rest of Rust:
impl<'a, 'b, T> Mul<&'b Mat<T>, Mat<T>> for &'a Mat<T> {
fn mul(&'a self, other: &'b Mat<T>) -> T { ... }
}
let m2: Mat<_> = &m0 * &m1;
It's not super clear to me how this is different from what you can do
right now, e.g. here's the Mul implementation from my linear algebra
library:
impl<'l,
RHS: VectorGet + Clone>
Mul<RHS, VectorBinOp<&'l Vector, RHS, OpMul>> for
&'l Vector
{
fn mul(&self, rhs: &RHS) -> VectorBinOp<&'l Vector, RHS, OpMul>
{
VectorBinOp::new(self.clone(), rhs.clone(), OpMul::new())
}
}
impl<'l>
VectorGet for
&'l Vector
{
...
}
The usage syntax (with the explicit borrowing and all) is the same.
-SL
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev