Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. struct LinuxCode;
  2.  
  3. fn target_specific_os() {
  4. if cfg!(target_os = "macos") {
  5. println!("Run the MacOS specific code");
  6. } else if cfg!(target_os = "linux") {
  7. println!("Run the Linux specific code");
  8.  
  9. let _lin = LinuxCode {};
  10. } else if cfg!(target_os = "windows") {
  11. println!("Run the Windows specific code");
  12. } else {
  13. eprintln!("I don't know this OS");
  14. }
  15. }
  16.  
  17. fn paths_n_modules() {
  18. let current_file = file!();
  19. let current_line = line!();
  20. let current_column = column!();
  21.  
  22. println!(
  23. "{file}, line {line}, column {col}",
  24. file = current_file,
  25. line = current_line,
  26. col = current_column,
  27. );
  28.  
  29. println!("{}", module_path!());
  30. }
  31.  
  32. fn main() {
  33. paths_n_modules();
  34. target_specific_os();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement