I'm working on a Rust program to manage a teacher's information, but I'm puzzled why my code updates the subject but not the teacher's name. Here's the relevant code: I'm creating a struct for the teacher with a name, ID, and subject. After adding a teacher with the name 'Hari Bahadur' and subject 'History', I try to update the subject to 'English' and the name to 'Hari only'. Although the output shows the updated subject correctly, the teacher's name doesn't seem to change as expected. Can someone help me understand what's going wrong?
1 Answer
When I run your code, I see:
The name of the teacher is Hari Bahadur
Now Hari only teaches English
The first line prints out the original name before you update it, while the second line shows the updated name after you make the changes. So it seems like your updates are working correctly; maybe you just misinterpreted the output?
So there is some problem with my cargo run it seems.