[−][src]Function tao_of_rust::ch02::primitives::bool_type
pub fn bool_type()
基本数据类型:布尔值
Basic usage:
fn bool_type() { let x = true; // bool类型可以自动推断 let y: bool = false; // bool值分为true和false let x = 5; if x > 1 { println!( "x is bigger than 1")}; // 比较操作会产生一个bool类型 assert_eq!(x as i32, 1); assert_eq!(y as i32, 0); // 通过as操作符可以将bool转换为数字 } bool_type();Run