Modifying values in a struct

I have made a struct and want to read and edit the values in that struct in for loop
for that I have written this code
struct PlayerScores{

If I have four players I want to insert the currentRoll in each iteration and add the currentROll to Total value of the struct.
Pleas can someone guide

To set/modify the value of a struct field:

// player_1 is an instance of PlayerScores

player1.current_roll = 5; // Sets the value of the current_roll field to 5 += 5;       // Increments the value of the total field by 5

If you're looping over a Vec of PlayerScores or something similar, you will need to do for player in &mut your_vec or for player in your_vec.iter_mut() to get mutable access to the items.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.