Skip to content

Instantly share code, notes, and snippets.

@Kimundi
Created December 30, 2012 22:14
Show Gist options
  • Select an option

  • Save Kimundi/4415551 to your computer and use it in GitHub Desktop.

Select an option

Save Kimundi/4415551 to your computer and use it in GitHub Desktop.
fn gen_to_str<T: Num Zero One Ord Round ToStr>(num: T) -> ~str {
let mut s = ~"";
let mut accum = num;
let _base: T = Num::from_int(10);
while(accum > Zero::zero()) {
let digit: T = accum % _base;
accum /= _base;
accum = accum.floor();
s = digit.to_str() + s;
}
s
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment