Advertisement
cwchen

[Rust] nested module demo.

Aug 23rd, 2017
1,374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.38 KB | None | 0 0
  1. mod english {
  2.     pub mod greeting {
  3.         pub fn hello(name: &str) {
  4.             println!("Hello, {}", name);
  5.         }
  6.     }
  7.  
  8.     pub mod farewell {
  9.         pub fn goodbye(name: &str) {
  10.             println!("Goodbye, {}", name);
  11.         }
  12.     }
  13. }
  14.  
  15. fn main() {
  16.     use english;
  17.  
  18.     english::greeting::hello("Michael");
  19.     english::farewell::goodbye("Michael");
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement