Structs are one of Rust's fundamental building blocks for creating custom types. They allow you to group together related data under one type, making your programs easier to understand and maintain. In this challenge, you'll work with Rust structs by creating a simple structure to represent a Person.
A struct in Rust can have named fields with different data types. For example:
rust
struct Book { name: String, author: String,}
Once defined, you can create instances of the struct and access or modify its fields using dot notation.
Your task is to define a struct called Person with the following fields:
name: A String representing the person's name.
age: A u8 representing the person's age.
You must also implement a function is_adult that takes a reference to a Person and returns true if the person's age is 18 or older, and false otherwise.
Structs are one of Rust's fundamental building blocks for creating custom types. They allow you to group together related data under one type, making your programs easier to understand and maintain. In this challenge, you'll work with Rust structs by creating a simple structure to represent a Person.
A struct in Rust can have named fields with different data types. For example:
rust
struct Book { name: String, author: String,}
Once defined, you can create instances of the struct and access or modify its fields using dot notation.
Your task is to define a struct called Person with the following fields:
name: A String representing the person's name.
age: A u8 representing the person's age.
You must also implement a function is_adult that takes a reference to a Person and returns true if the person's age is 18 or older, and false otherwise.