&str1 [Rust] Ownership(소유권) 기초 예제 : &str (37일차) [예제 코드_1] fn main() { let name: &'static str = "Rust"; do_something(name); do_something(name); } fn do_something(name: &str) { println!("Hello, {:?}!", name); } [실행 결과] Hello, Rust! Hello, Rust! [예제 코드_2] fn main() { let name: &'static str = "Rust"; do_something(name.clone()); do_something(name.clone()); } fn do_something(name: &str) { println!("Hello, {:?}!", name); } [실행 결과] Hello, Rust! Hello.. 2023. 1. 20. 이전 1 다음