Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Pet Struct

Define a struct called Pet with two fields: name (String) and species (String). Create a pet named "Buddy" who is a "dog", then print its info.

Expected output:

text
Buddy is a dog

Hints:

  • Define the struct outside main: struct Pet { name: String, species: String }
  • Use String::from("Buddy") for String values
  • Access fields with pet.name and pet.species
rust
fn main() {
}