servo / euclid

Geometry primitives (basic linear algebra) for Rust
Other
458 stars 102 forks source link

Implement operator overloading symmetrically #400

Open HalfVoxel opened 4 years ago

HalfVoxel commented 4 years ago

Several operators do not work when switching the order of the arguments, which makes writing code tedious.

// Compiles
let a = point(1.0, 1.0) * 5.0;

// Does not compile
let a = 5.0 * point(1.0, 1.0);

It seems like a limitation in rust prevented this from being implemented a few years ago. However afaik this limitation has been lifted.

Is there any reason the symmetrical traits have not been implemented yet?

nical commented 4 years ago

No particular reason (I didn't know a restriction had been lifted).

nical commented 4 years ago

It's still not quite clear to me how to implement this. Do you want to give it a go ?