calculator in rust

Here's an example of a calculator program written in Rust:

use std::io;

fn main() {
    let mut input = String::new();

    println!("Enter an expression:");

    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");

    let result = eval(&input);

    println!("Result: {}", result);
}

fn eval(input: &str) -> f64 {
    let tokens: Vec<&str> = input.trim().split_whitespace().collect();

    let operand1: f64 = tokens[0].parse().expect("Invalid number");
    let operator = tokens[1];
    let operand2: f64 = tokens[2].parse().expect("Invalid number");

    match operator {
        "+" => operand1 + operand2,
        "-" => operand1 - operand2,
        "" => operand1  operand2,
        "/" => operand1 / operand2,
        _ => panic!("Invalid operator"),
    }
}

To use this calculator, you can run the program and enter an expression in the format operand1 operator operand2. For example, you can enter 2 + 3 and the program will output 5.

Please note that this is a simple calculator program and does not handle more complex expressions or error cases. You can modify and expand it according to your needs.

Let me know if you need further assistance!