Compiling playground v0.0.1 (/playground)
error[E0689]: can't call method `copy` on ambiguous numeric type `{integer}`
--> src/main.rs:3:13
|
3 | let b=a.copy();
| ^^^^
|
help: you must specify a type for this binding, like `i32`
|
2 | let a: i32=1;
| ~~~~~~
For more information about this error, try `rustc --explain E0689`.
error: could not compile `playground` due to previous error
I'm not entirely sure why the error message looks the way it looks, but integer types in Rust simply don't have any method called copy. You can copy them implicitly by just writing let b = a;.
There is a method called .clone(), but no method named .copy(). The Copy trait works by changing how moves work - it doesn't work by introducing a new method.