코딩Coding/Rust연습
Rust연습❤️) Collect & Vec 조합 Closure활용
내인생PLUS
2022. 6. 23. 17:51
728x90
fn main() {
let my_vec = ((-10..=10).map(|x| (x, x* x))).collect::<Vec<_>>();
println!("{my_vec:?}");
}
결과 :
Standard Error
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 4.09s
Running `target/debug/playground`
Standard Output
[(-10, 100), (-9, 81), (-8, 64), (-7, 49), (-6, 36), (-5, 25), (-4, 16), (-3, 9), (-2, 4), (-1, 1), (0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25), (6, 36), (7, 49), (8, 64), (9, 81), (10, 100)]
Rust❤️take & collect methods 사용법 1분 53초에 나옴 & skip(3분30초 -
https://economiceco.tistory.com/m/14121
반응형