Conditional Compilation in Rust
Today I learnt that certain rust code can be marked such that it is compiled only for specific platform.
This makes sense for low level libraries that provide platform-specific functionality that is not available on other platforms.
This is achieved by tagging the function with #[cfg(target_os = "xyz")]
Here xyz can be one of the following :
- “windows”
- “macos”
- “ios”
- “linux”
- “android”
- “freebsd”
- “dragonfly”
- “openbsd”
- “netbsd”
Similar to target_os, here are other options :