如何在 Rust 中将布尔值转换为整数?

问题描述:

如何在 Rust 中将布尔值转换为整数?如在,true 变为 1,false 变为 0.

How do I convert a boolean to an integer in Rust? As in, true becomes 1, and false becomes 0.

Cast it:

fn main() {
    println!("{}", true as i32)
}