Complete the code to define a struct named Person.
struct [1] {
name: String,
age: u32,
}The struct name should start with a capital letter by convention. Here, Person is the correct name.
Complete the code to create an instance of the Person struct.
let person = Person {
name: String::from("Alice"),
[1]: 30,
};years or number.The field for age in the struct is named age, so we must use age when creating an instance.
Fix the error in the struct definition by completing the missing keyword.
[1] Person {
name: String,
age: u32,
}fn or let instead of struct.To define a struct in Rust, you must use the struct keyword before the name.
Fill both blanks to define a struct named Car with fields make and year.
[1] Car { make: String, [2]: u32, }
fn instead of struct.model.The keyword struct starts the definition, and the field for the year is named year.
Fill all three blanks to create an instance of Book with fields title, author, and pages.
let book = Book {
title: String::from([1]),
author: String::from([2]),
pages: [3],
};We create a Book instance by providing the title, author, and number of pages. The title is "The Rust Book", the author is "Steve Klabnik", and pages is 550.
