Preview:
// rgb to hex conversion
fn rgb(r: i32, g: i32, b: i32) -> String {
    format!("{:02X}{:02X}{:02X}", 
        r as f32 as u8, 
        g as f32 as u8, 
        b as f32 as u8) 
}

fn main() {
    let (r, g, b) = (123, 86, 200);
    println!("rgb {} {} {} to hex {} ", r, g, b, rgb(r, g, b));
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter