-
Rust] #[cfg(not(target_os = "linux"))] // configuration코딩Coding/★Rust★기초★Syntax 2022. 3. 12. 21:36728x90
// #[cfg(not(target_os = "linux"))] // configuration // This function only gets compiled if the target OS is linux #[cfg(target_os = "linux")] fn are_you_on_linux() { println!("You are running linux!"); } // And this function only gets compiled if the target OS is *not* linux #[cfg(not(target_os = "linux"))] fn are_you_on_linux() { println!("You are *not* running linux!"); } fn main() { are_you_on_linux(); println!("Are you sure?"); if cfg!(target_os = "linux") { println!("Yes. It's definitely linux!"); } else { println!("Yes. It's definitely *not* linux!"); } }
출처 :
https://doc.rust-lang.org/rust-by-example/attribute/cfg.html
반응형'코딩Coding > ★Rust★기초★Syntax' 카테고리의 다른 글
ToOwned, Borrow처럼 Rust공식Doc볼때 보라색 표시는 Trait라는 뜻이다.!! (0) 2022.03.14 How Rust Uses Ownership To Save Your Programs | Rust Toturial (0) 2022.03.14 Rust Cologne: ❤️Fn traits (0) 2022.03.13 Rust](시간, 초trait나옴 ❤️Traits and trait objects - more than just interfaces - Rust Community Stuttgart (0) 2022.03.13 Implementing and Optimizing a Wordless Solver in Rust- Jon Gjengset (0) 2022.03.12 Rust] ❤️Struct & Traits & impls ❤️ (0) 2022.03.12 3 Rust Concepts For Game Development- Coding Tech (0) 2022.03.12 Rust] What's is that Entity?(19분에 나옴) (0) 2022.03.11