for loop1 [Rust] Ownership(소유권) 기초 예제 : For Loop (35일차) [예제 코드_1] fn main() { let names = vec![ String::from("John"), String::from("Jane"), ]; for name in names { println!("{}", name); } } [실행 결과] John Jane [예제 코드_2] fn main() { let names = vec![ String::from("John"), String::from("Jane"), ]; for name in names { println!("{}", name); } println!("Names: {:?}", names); } [실행 결과] error[E0382]: borrow of moved value: `names` --> src/main.rs:11:29 [예제 코드_.. 2023. 1. 18. 이전 1 다음