daily pastebin goal
35%
SHARE
TWEET

[Rust] A complex module calling demo.

cwchen Aug 23rd, 2017 (edited) 167 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top