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.nameandpet.species
rust
fn main() {
}