You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnmain(){let v = gen(1000);println!("{:?}", v);assert_eq!(gen(1_000_000_000).len(),1023);}fngen(n:u64) -> Vec<u64>{letmut v = vec![0];letmut i = 0;letmut len = 1;letmut w = 1;loop{for k in[4,7].into_iter(){letmut x = i;let y = i + len;while x < y {let z = k * w + v[x];if n < z {return v;}
v.push(z);
x += 1;}}
w *= 10;
i += len;
len *= 2;}}
Compiling playground v0.0.1 (/playground)
error[E0277]: cannot add `u64` to `i32`
--> src/main.rs:17:31
|
17 | let z = k * w + v[x];
| ^ no implementation for `i32 + u64`
|
= help: the trait `std::ops::Add<u64>` is not implemented for `i32`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground`.
When I change the for line for k in [4, 7].into_iter() { to for k in [4, 7].into_iter().copied {, there's no compile error. I think there's a bug in type inference for &{integer}.
The text was updated successfully, but these errors were encountered:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=81011b06836fc24bd4649a9358207ba9
Expected output:
Instead, I get:
When I change the for line
for k in [4, 7].into_iter() {
tofor k in [4, 7].into_iter().copied {
, there's no compile error. I think there's a bug in type inference for &{integer}.The text was updated successfully, but these errors were encountered: