Consider following code:
fn main() {
let i = f32::consts::PI;
}
With following error:
$ rustc --version
rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
$ rustc -
<anon>:2:13: 2:28 error: ambiguous associated type; specify the type using the syntax `<f32 as Trait>::consts` [E0223]
<anon>:2 let i = f32::consts::PI;
^~~~~~~~~~~~~~~
error: aborting due to previous error
- Why does it complain about an "associated type"? The only type I see here is
f32
, which is not associated. - Why is this ambigious? I clearly specified the
f32
. - What is this
<f32 as Trait>::consts
syntax? I've never seen it before. - And, obviously, what can I do to fix this error and get my variable set to PI?