quant 0.0.2

A library that makes it easy to work w/ Dimensions, Units, and Physical Quantities.
use num::bigint::{BigDigit,BigInt};
use num::rational::Ratio;
use num::bigint::ToBigInt;

use std::str::FromStr;

pub fn to_ratio(string: &str) -> Ratio<BigInt> {
  let mut numer_digits: Vec<BigDigit> = Vec::new();

  let mut nums: Vec<&str> = string.split("").collect();

  let (mut denom_zeroes, mut after_dec): (usize, bool) = (0, false);

  nums.retain(|n| *n != "");

  for n in nums.iter() {
    match *n {
      "." => { after_dec = true },
      _ => { 
        if after_dec { denom_zeroes += 1 }
        numer_digits.push(u32::from_str(n).unwrap());
      }
    }
  }

  nums.retain(|n| *n != ".");

  let mut s = String::new();

  for n in nums.iter() { s.push_str(n) }

  let numer = BigInt::from_str(s.as_ref()).unwrap();
  let denom = ::num::pow((10u32).to_bigint().unwrap(), denom_zeroes);
  Ratio::new(numer, denom)
}