Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Latest commit

 

History

History
36 lines (26 loc) · 927 Bytes

instructions.md

File metadata and controls

36 lines (26 loc) · 927 Bytes

You're working on implementing a health-monitoring system. As part of that, you need to keep track of users' health statistics.

You'll start with some stubbed functions in an impl block as well as the following struct definition:

pub struct User {
    name: String,
    age: u32,
    weight: f32,
}

Your goal is to implement the stubbed out methods on the User struct defined in the impl block.

For example, the new method should return an instance of the User struct with the specified name, age, and weight values.

let mut bob = User::new(String::from("Bob"), 32, 155.2);
// Returns: a User with name "Bob", age 32, and weight 155.2

The weight method should return the weight of the User.

bob.weight();
// Returns: 155.2

The set_age method should set the age of the User.

bob.set_age(33);
// Updates Bob's age to 33; happy birthday Bob!

Have fun!