Advertisement
cwchen

[Rust] A complex module calling demo.

Aug 23rd, 2017
1,387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.69 KB | None | 0 0
  1. // Rename crate
  2. extern crate phrases as sayings;
  3.  
  4. // Rename module
  5. use sayings::japanese::greetings as ja_greetings;
  6.  
  7. // Glob all functions in a module, NOT a good style
  8. use sayings::japanese::farewells::*;
  9.  
  10. // A complex renaming scheme
  11. use sayings::english::{self, greetings as en_greetings, farewells as en_farewells};
  12.  
  13. fn main() {
  14.     println!("Hello in English; {}", en_greetings::hello());
  15.     println!("And in Japanese: {}", ja_greetings::hello());
  16.     println!("Goodbye in English: {}", english::farewells::goodbye());
  17.     println!("Again: {}", en_farewells::goodbye());
  18.  
  19.     // Use a globbed function, AVOID it when possible.
  20.     println!("And in Japanese: {}", goodbye());
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement