1 2 3 4 | fn main() { println!( "Hello World."); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | mod bits { fn pos(bit: u32) -> u32 { 1 << bit } pub fn decimal(bit: u32) { println!("Bits decimal {}", pos(bit)); } pub fn hex(bit: u32) { println!("Bits decimal 0x{:x}", pos(bit)); } } fn main( ) { bits::decimal(8); bits::hex(8); } // Bits decimal 256 // Bits decimal 0x100 |
1 2 3 4 5 6 7 8 | fn main() { let a = 1; let rawp = &a as *const i32; unsafe { println!("rawp is {}", *rawp); } } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |