Closed
Description
I might be missing something but I believe the following (playpen) should compile but does not:
use std::ops::Mul;
fn main() {
}
trait Ring { }
trait Real: Ring { }
trait Module: Sized + Mul<<Self as Module>::Ring, Output = Self> {
type Ring: Ring;
}
trait EuclideanSpace {
type Coordinates: Module<Ring = Self::Real>;
type Real: Real;
}
pub trait Translation<E: EuclideanSpace> {
fn to_vector(&self) -> E::Coordinates;
fn powf(&self, n: <E::Coordinates as Module>::Ring) -> E::Coordinates {
self.to_vector() * n
}
}
In self.to_vector() * n
, the compiler seems to understand that <E::Coordinates as Module>::Ring>
is the same thing as E::Real
but fails to applies the Mul<<Self as Module>::Ring, Output = Self>
trait from Module
.