Skip to content

Instantly share code, notes, and snippets.

@jfager
Created June 25, 2013 10:50
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 jfager/5857599 to your computer and use it in GitHub Desktop.
Save jfager/5857599 to your computer and use it in GitHub Desktop.
fn ip6_to_str(ip6: &[u8]) -> ~str {
let f = u8::to_str_radix;
return fmt!("%s%s:%s%s:%s%s:%s%s:%s%s:%s%s:%s%s:%s%s",
f(ip6[ 0], 16), f(ip6[ 1], 16),
f(ip6[ 2], 16), f(ip6[ 3], 16),
f(ip6[ 4], 16), f(ip6[ 5], 16),
f(ip6[ 6], 16), f(ip6[ 7], 16),
f(ip6[ 8], 16), f(ip6[ 9], 16),
f(ip6[10], 16), f(ip6[11], 16),
f(ip6[12], 16), f(ip6[13], 16),
f(ip6[14], 16), f(ip6[15], 16)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment