728x90 rust drop1 [Rust lang] 90. fn mut fnonce fn fn_closure(f: F) where F: Fn() { f(); } fn fn_mut_closure(mut f: F) where F: FnMut(), { f(); } fn fn_once_closure(f: F) where F: FnOnce(), { f(); } fn main() { let mut my_string = String::from("Hello there"); /* let print_it = || { drop(my_string); }; print_if(); */ fn_once_closure(|| { my_string.push('a); println!("{my_string}"); drop(my_string); }) } Rust 2023. 3. 30. 이전 1 다음 728x90