fn perform_ops_int(lhs: i64, op: Operator, rhs: i64)
-> Result<i64, ShellError> {
    use Operator::*;
    let unsupported_err: &'static str = 
    "oyster: assignment operators are currently unsupported";
    match op {
        Add => {
            if lhs == i64::MAX {
                return Err(ShellError::from("error: variable overflow"))
            }
            Ok(lhs + rhs)
        }
        Sub => {
            if lhs == i64::MIN {
                return Err(ShellError::from("error: variable underflow"))
            }
            Ok(lhs - rhs)
        }
        Mul => {
            if lhs as i128 * rhs as i128 >= i64::MAX as i128 {
                return Err(ShellError::from("error: variable overflow"))
            }
            Ok(lhs * rhs)
        }
        Div => {
            Ok(lhs / rhs)
        }
        _ => {
            Err(ShellError::from(unsupported_err))
        }
    }
}
//Note: I wanted to do generics here but the kind of trait bounds
//required to use for the items I wanted to return are not supported by Rust.
I wanted to do generics here but the kind of trait bounds
required to use for the items I wanted to return are not supported by Rust.
I wanted to do generics here but the kind of trait bounds required to use for the items I wanted to return are not supported by Rust .
fn perform_ops_int(lhs: i64, op: Operator, rhs: i64)
-> Result<i64, ShellError> {
    use Operator::*;
    let unsupported_err: &'static str = 
    "oyster: assignment operators are currently unsupported";
    match op {
        Add => {
            if lhs == i64::MAX {
                return Err(ShellError::from("error: variable overflow"))
            }
            Ok(lhs + rhs)
        }
        Sub => {
            if lhs == i64::MIN {
                return Err(ShellError::from("error: variable underflow"))
            }
            Ok(lhs - rhs)
        }
        Mul => {
            if lhs as i128 * rhs as i128 >= i64::MAX as i128 {
                return Err(ShellError::from("error: variable overflow"))
            }
            Ok(lhs * rhs)
        }
        Div => {
            Ok(lhs / rhs)
        }
        _ => {
            Err(ShellError::from(unsupported_err))
        }
    }
}
fn perform_ops_int ( lhs : i64 , op : Operator , rhs : i64 ) -> Result < i64 , ShellError > { use Operator :: * ; let unsupported_err : & ' static str = " " ; match op { Add => { if lhs == i64 :: MAX { return Err ( ShellError :: from ( " " ) ) } Ok ( lhs + rhs ) } Sub => { if lhs == i64 :: MIN { return Err ( ShellError :: from ( " " ) ) } Ok ( lhs - rhs ) } Mul => { if lhs as i128 * rhs as i128 >= i64 :: MAX as i128 { return Err ( ShellError :: from ( " " ) ) } Ok ( lhs * rhs ) } Div => { Ok ( lhs / rhs ) } _ => { Err ( ShellError :: from ( unsupported_err ) ) } } }
Note: I wanted to do generics here but the kind of trait bounds
required to use for the items I wanted to return are not supported by Rust.
Note : I wanted to do generics here but the kind of trait bounds required to use for the items I wanted to return are not supported by Rust .
lhs
i64
op
Operator
rhs
i64