Created
January 4, 2022 16:26
-
-
Save eduardonunesp/8d02aeed2d36f076a80a37279d06f2bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let str_to_int = u64::from_str_radix(&"10", 10).expect("Not an integer"); | |
let int_string = "1000000".to_string(); | |
let parse_int: u64 = "1000000".parse().unwrap(); | |
let parse_int: u64 = "1000000".parse::<u64>().unwrap(); // Turbo fish syntax ::<>() | |
let padded = format!("{:08.2}", 1000.1234); // 00001000.12 | |
let pad_left = format!("{txt:=<width$}", txt="text", width=20); // left padded to a variable place with = as padding | |
let pad_right = format!("{:=>7}", "text"); // right padded to 7 places with = as padding | |
let justified = format!("{:=^width$}", "text", 12); // centered with = on both sides |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment