Crate platform [−] [src]
This crate provides an easy way to inline selection of input parameters
based on the platform being targeted. Can be used on any Sized
type.
This is guaranteed to be a zero cost abstraction, as all calls are inlined.
extern crate platform; use platform::Platform; fn main() { println!("Hello from {}!", "unknown" .ios("ios") .android("android") .windows("windows") .macos("macos") .linux("linux") .wasm32("wasm32") .emscripten("emscripten") ); // Alternatively, let's pretend the arguments are non-trivial to evaluate. // We can also use this on function pointers so long as all the variants can // coerce to the same function pointer type. println!("Hello from {}!", ((|| String::from("unknown")) as fn() -> String) .ios(|| String::from("ios")) .android(|| String::from("android")) .windows(|| String::from("windows")) .macos(|| String::from("macos")) .linux(|| String::from("linux")) .wasm32(|| String::from("wasm32")) .emscripten(|| String::from("emscripten")) () ); }
Traits
Platform |