Rust: function
/** * file: nested.rs * IDE: vscode * */ ///公有函数 pub fn function() { println!("called `my::nested::function()`"); } ///私有函数 #[allow(dead_code)] fn private_function() { println!("called `my::nested::private_function()`"); }
/** * file inaccessibler.rs * https://code.visualstudio.com/docs/languages/rust */ ///公有函数 #[allow(dead_code)] pub fn public_function() { println!("called `my::inaccessible::public_function()`"); }
/** * file: my.rs * * * */ mod inaccessible; //从文件 inaccessible.rs pub mod nested; //从文件 nested.rs ///公有函数 pub fn function() { println!("called `my::function()`"); } ///私用函数 fn private_function() { println!("called `my::private_function()`"); } ///公有函数 pub fn indirect_access() { print!("called `my::indirect_access()`, that\n> "); private_function(); }
调用:
mymod::function(); //windows_gui::GuiFactory(); my::function(); my::indirect_access(); my::nested::function(); let windows = true;
Code Runner 安装插件,代码一键运行
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)