[rust-dev] Conflicting implementations of a trait

Corey Richardson corey at octayn.net
Tue Jul 22 10:14:42 PDT 2014


Not right now. Extending the language to allow this is the subject of
RFC 24: https://github.com/rust-lang/rfcs/blob/master/active/0024-traits.md

On Tue, Jul 22, 2014 at 9:50 AM, Allen Welkie <allen.welkie at gmail.com> wrote:
> Can there be two simultaneous implementations of a generic trait? I ask
> because I want to extend the Complex class to allow for multiplication by
> scalars, so that you can use "a * b" where "a" and "b" can be either scalars
> or Complex.
>
> The Complex struct already has an implementation of the Mul trait. I wanted
> to add another, so I added the implementation of Mul<T, Complex<T>> for
> Complex<T>, and used the scale() function. But I get a compiler error saying
> that there are conflicting implementations for trait 'core::ops::Mul'.
>
> Is it possible to simultaneously overload the Complex (*) operator scalars
> and complex numbers?
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>



-- 
http://octayn.net/


More information about the Rust-dev mailing list