Created
February 9, 2015 07:16
-
-
Save mitchmindtree/98d1322e7b73ebad6783 to your computer and use it in GitHub Desktop.
Strange associated types behaviour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::num::Float; | |
trait Foo { | |
type A: Float; | |
// Why is it that this doesn't work... | |
fn sub_a(&self, a: <Self as Foo>::A, b: <Self as Foo>::A) -> <Self as Foo>::A { | |
a - b | |
} | |
// ... and this does. | |
fn sub_b(&self, a: <Self as Foo>::A, b: <Self as Foo>::A) -> <Self as Foo>::A { | |
fn sub<T: Float>(a: T, b: T) -> T { a - b } | |
sub(a, b) | |
} | |
} | |
fn main() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment