I want my string to be displayed with 4 characters like this: "a" -> "a " when I do format!("{}", "a").
I read the format documentation, and tried several solutions like {:<4} but it didn't work.
As fjh says, this works:
fn main() {
assert_eq!("a ", format!("{:<4}", 'a'));
assert_eq!("a ", format!("{:<4}", "a"));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With