Skip to content

Instantly share code, notes, and snippets.

@wess
Created October 29, 2020 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wess/30c2248695a816af1dddabe87c050b99 to your computer and use it in GitHub Desktop.
Save wess/30c2248695a816af1dddabe87c050b99 to your computer and use it in GitHub Desktop.
let hex_string = match hex.len() {
3 => format!(
"{}{}{}{}{}{}",
&hex[..1],
&hex[..1],
&hex[1..2],
&hex[1..2],
&hex[2..3],
&hex[2..3]
),
6 => hex.to_string(),
l => {
println!("{} has length of {}, expected 3 or 6", hex, l);
std::process::exit(128)
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment