Skip to content

Multiplying only works one direction #20118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mdinger opened this issue Dec 21, 2014 · 1 comment
Closed

Multiplying only works one direction #20118

mdinger opened this issue Dec 21, 2014 · 1 comment

Comments

@mdinger
Copy link
Contributor

mdinger commented Dec 21, 2014

Multiply only works when called directly or when inverted (len * 3.0).

#[deriving(Copy, Show)]
pub struct Len(f64);

impl Mul<Len, Len> for f64 {
    fn mul(self, r: Len) -> Len {
        let Len(right) = r;

        Len(self * right)
    }
}

fn main() {
    let len = Len(12.0);

    // works
    println!("{}", 3.0.mul(len));
    // doesn't
    println!("{}", 3.0 * len);
}
@mdinger
Copy link
Contributor Author

mdinger commented Dec 21, 2014

Ah, seems to be a duplicate of #19035

@mdinger mdinger closed this as completed Dec 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant