Function lib_xch::handler::handler_api [] [src]

pub fn handler_api<T: CheckedType>(
    equation: &str
) -> Result<ResultHandler<Vec<T>>, ErrorHandler<T>>

the API balances the Chemical Equation by equation. It provides one balanced solution, but it may isn't the most correct solution (because it set all free variables = 1). If the equation can balance, function would return a T vector which contains the answer. If not, it would return handler::ErrorHandler which contains Delta-3 the parser's result and error message.

Panics

The equation you provided should be a common unbalanced chemical equation which only contains one =.

  • Stack Overflow may cause panic. Because it is using regex-based parser.
  • The implement for PartialOrd and PartialEq trait may cause panic. Because it should return Ordering.

And in the other failed situation, it'll return a error_message and contain parser_result(maybe it is empty).