Last active
June 30, 2021 11:06
-
-
Save lunandd/c79a80e1531060dd623c5428199eb293 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
fn main() { | |
println!("{}", rgb_to_hex(171, 205, 239)); | |
} | |
fn rgb_to_hex(r: u8, g: u8, b: u8) -> String { | |
let mut hex: String = "".into(); | |
let rgb_colors: [u8; 3] = [r, g, b]; | |
for color in rgb_colors.iter() { | |
hex.push_str( &(format!("{:02x?}", color)) ) | |
} | |
"#".to_owned() + &hex | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment