Replace infix, prefix, etc. with one method:
pub trait BergValue<'a> {
...
/// Perform an operation on this BergValue, and return the result as well
/// as the updated BergValue.
///
/// Returns:
/// - `Err(error)` if there was an error performing this operation.
/// - `Ok((current, new_self))` if the operation worked out fine.
fn operate(self, operation: Operation<impl BergValue<'a>>) -> BergResult<'a, (BergResult<'a>, BergResult<'a>)>;
}
pub enum Operation<Operand> {
Infix { operator: IdentifierIndex, is_assign: bool, right: Operand },
Postfix { operator: IdentifierIndex },
Prefix { operator: IdentifierIndex },
SubExpression { boundary: ExpressionBoundary },
Field { field: IdentifierIndex },
SetField { field: IdentifierIndex, value: Operand },
NextVal
}
Replace infix, prefix, etc. with one method:
The intent is threefold: