Add some documentation, and clean up EvalError a bit.
This commit is contained in:
@@ -68,7 +68,11 @@ impl Value {
|
||||
/// Calculate the result of running the given primitive on the given arguments.
|
||||
///
|
||||
/// This can cause errors in a whole mess of ways, so be careful about your
|
||||
/// inputs.
|
||||
/// inputs. For example, addition only works when the two values have the exact
|
||||
/// same type, so expect an error if you try to do so. In addition, this
|
||||
/// implementation catches and raises an error on overflow or underflow, so
|
||||
/// its worth being careful to make sure that your inputs won't cause either
|
||||
/// condition.
|
||||
pub fn calculate(operation: &str, values: Vec<Value>) -> Result<Value, PrimOpError> {
|
||||
if values.len() == 2 {
|
||||
Value::binary_op(operation, &values[0], &values[1])
|
||||
|
||||
Reference in New Issue
Block a user