Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct LinuxCode;
- fn target_specific_os() {
- if cfg!(target_os = "macos") {
- println!("Run the MacOS specific code");
- } else if cfg!(target_os = "linux") {
- println!("Run the Linux specific code");
- let _lin = LinuxCode {};
- } else if cfg!(target_os = "windows") {
- println!("Run the Windows specific code");
- } else {
- eprintln!("I don't know this OS");
- }
- }
- fn paths_n_modules() {
- let current_file = file!();
- let current_line = line!();
- let current_column = column!();
- println!(
- "{file}, line {line}, column {col}",
- file = current_file,
- line = current_line,
- col = current_column,
- );
- println!("{}", module_path!());
- }
- fn main() {
- paths_n_modules();
- target_specific_os();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement