Question: Write a program using the language Rust. ## Description Write a [postfix](https://en.wikipedia.org/wiki/Reverse_Polish_notation) expression evaluator. An expression consists of operands and operators. An operand is a
Write a program using the language Rust.
## Description Write a [postfix](https://en.wikipedia.org/wiki/Reverse_Polish_notation) expression evaluator. An expression consists of operands and operators. An operand is a signed integer (`isize`). An operator is `+`, `-`, or `*` with their common semantics. An expression is valid if it can be evaluated to a signed integer. For example, the following are valid expressions: ``` -100 1 2 + 1 2 3 + * ``` The following expressions are invalid: ``` // empty expression -1 -2 1 2 + * ``` ## Public API Your program must provide the following public API. ``` pub enum Operator { // `+` Add, // `-` Sub, // `*` Mul, } pub enum Token { Operator(Operator), Operand(isize), } /// Evaluates the postix expression. /// /// Input: a postfix expression, where each element contains an operator or operand. /// Returns: if the postfix expression is valid, returns `Some(value)`; /// otherwise, returns `None`. pub fn eval(tokens: &[Token]) -> Option { // TODO unimplemented!(); } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
