for expressions
forํํ์์ while let ํํ์๊ณผ ๋งค์ฐ ์ ์ฌํฉ๋๋ค. forํํ์์ ์๋์ผ๋ก into_iter()๋ฅผ ํธ์ถํ ๋ค์ ์ด๋ฅผ ๋ฐ๋ณตํฉ๋๋ค.
The
forexpression is closely related to thewhile letexpression. It will automatically callinto_iter()on the expression and then iterate over it:
fn main() { let v = vec![10, 20, 30]; for x in v { println!("x: {x}"); } }
์ญ์ ๋ค๋ฅธ์ธ์ด์ ๋ง์ฐฌ๊ฐ์ง๋ก break ์ continue๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
You can use
breakandcontinuehere as usual.