public/subjects/lifetimes
davhojt 3cd40e5cc3 docs(lifetimes) correct grammar 2022-06-13 00:46:37 +03:00
..
README.md docs(lifetimes) correct grammar 2022-06-13 00:46:37 +03:00

README.md

lifetimes

Instructions

Complete the Person struct with the fields and associated function described below. new should set the age to 0.

Expected Functions and Data Structures (Both need to be completed)

#[derive(Debug)]
pub struct Person{
	pub name: &str,
	pub age: u8,
}

impl Person {
	pub fn new(name: &str) -> Person {
	}
}

Usage

Here is a program to test your function.

use lifetimes::*;

fn main() {
	let person = Person::new("Leo");

	println!("Person = {:?}", person);
}

And its output:

$ cargo run
Person = Person { name: "Leo", age: 0 }
$

Notions