rust sum and average of number list

To calculate the sum and average of a number list in Rust, you can use the following code:

fn main() {
    let numbers = vec![1, 2, 3, 4, 5];
    let sum: i32 = numbers.iter().sum();
    let average = sum as f32 / numbers.len() as f32;
    println!("Sum: {}", sum);
    println!("Average: {}", average);
}

In this code, we first define a vector called numbers that contains the list of numbers. Then, we use the iter() method to iterate over the numbers and calculate the sum using the sum() method. Next, we calculate the average by dividing the sum by the length of the vector. Finally, we print the sum and average using println!().

Please note that this code assumes that you have a list of numbers stored in a vector. You can modify the numbers vector to include your desired list of numbers.

I hope this helps! Let me know if you have any further questions.