Quantcast
Channel: How do I convert a boolean to an integer in Rust? - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by wasmup for How do I convert a boolean to an integer in Rust?

$
0
0

You may use .into():

let a = true;let b: i32 = a.into();println!("{}", b); // 1let z: isize = false.into();println!("{}", z); // 0

playground


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>