Is there a way to convert a decimal to a 16-bit binary in Rust using the standard library?
I have this sample:
let x: u16 = 21;
println!("{}",format!("{:b}", x)); // output: 10101
but I need it to include the leading zeroes. like: 21
to 0000000000010101
I could create a function to add the leading zeroes but I was wondering if I'm missing something in its standard library.
Here are the methods from the std on u16 primitive type: https://doc.rust-lang.org/stable/std/primitive.u16.html