在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
原文:https://www.educative.io/edpresso/modules-in-rust --------------------------- In Rust, modules are containers that enclose zero or more items (i.e., functions, structs, traits, CodeThe mod external_mod { pub fn public_func() { println!("Public function called\n"); } fn private_func(){ println!("Private function called\n"); } pub fn private_func_accessor() { println!("Accessing private function with a public function"); private_func(); } mod internal_mod { pub fn public_internal_func() { println!("Public function inside internal mod called\n"); } } pub fn internal_mod_accessor() { println!("Accessing internal mod with a public function"); internal_mod::public_internal_func(); } } fn main() { external_mod::public_func(); external_mod::private_func_accessor(); external_mod::internal_mod_accessor(); }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论