Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Student Struct

Define a struct called Student with two fields: name (String) and grade (String). Create a student named "Emma" who got a grade of "A+", then print their result.

Expected output:

text
Emma got A+

Hints:

  • Define the struct with name: String and grade: String
  • Use String::from(...) when setting field values
  • Print with println!("{} got {}", student.name, student.grade)
rust
fn main() {
}