#E0068: 반복할 수 없는 값
for는 시작이 있는 정수 범위(0..n, 0..), 배열, IntoIterator나 Iterator(next가 T | none을 반환)를 구현한 타입을 반복합니다. try for는 TryIterator를 반복합니다. 이 중 하나를 반복하거나, 반복자를 주는 메서드를 부르세요.
nabi
struct Bag { n: i32; }
let b = Bag { n: 3 };
for x in b {
println(f"{x}");
}
error[E0068]: cannot iterate over a value of type `Bag` - `for` needs an integer range, an array, an `IntoIterator` / `Iterator` impl, or a `TryIterator` (`try for`) --> main.nabi:4:1 | 4 | for x in b { | ^^^^^^^^^^^^
범위, 컬렉션, 반복자를 반복하세요.
nabi
struct Bag { n: i32; }
let b = Bag { n: 3 };
for x in 0..b.n {
println(f"{x}");
}
0
1
2
관련 코드: E0069 트레잇 바운드를 만족하지 않음
잘못된 곳이 있나요? GitHub에서 이 페이지 고치기. 마지막 수정