https://zhuanlan.zhihu.com/p/18341231954
// This function only gets compiled if the target OS is linux #[cfg(target_os = "linux")] fn 在跑 linux() { println!("你在跑 linux!"); } // And this function only gets compiled if the target OS is *not* linux #[cfg(not(target_os = "linux"))] fn 在跑 linux() { println!("你昧在跑 linux!"); } fn main() { 在跑 linux(); println!("确定?"); if cfg!(target_os = "linux") { println!("是。的确!"); } else { println!("是。不是!"); } }
![]() | 1 xuanwu OP 一: https://zhuanlan.zhihu.com/p/17478754925 二、错误处理之 panic!: https://zhuanlan.zhihu.com/p/17837138618 三、错误处理之 abort 、unwind: https://zhuanlan.zhihu.com/p/17949281249 五、trait 之零: https://zhuanlan.zhihu.com/p/18807895424 六、trait 之 dyn: https://zhuanlan.zhihu.com/p/19024630655 |
![]() | 2 xuanwu OP Rust 在线摸索(七):struct https://zhuanlan.zhihu.com/p/19252635602 |
![]() | 3 xuanwu OP Rust 在线摸索(八):泛型没入门 https://zhuanlan.zhihu.com/p/19374376642 |
![]() | 4 xuanwu OP Rust 在线摸索(九):泛型之函数 https://zhuanlan.zhihu.com/p/19555812533 |
![]() | 5 xuanwu OP Rust 在线摸索(十):泛型之实现 https://zhuanlan.zhihu.com/p/19738859950 |
![]() | 6 xuanwu OP Rust 在线摸索(十一):泛型之 trait 、bounds https://zhuanlan.zhihu.com/p/19935885279 |
![]() | 7 xuanwu OP Rust 在线摸索(十二):泛型之 where 、反面代码初探 https://zhuanlan.zhihu.com/p/20081053824 |