You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Michele Sessa 31833e4418 refactor(tuples_refs): change id type for more idiomatic rust 2 years ago
..
README.md refactor(tuples_refs): change id type for more idiomatic rust 2 years ago

README.md

tuples_refs

Instructions

  • Define a tuple struct to represent a Student. Each is identified by an id of type u32, their first name and last name.

  • Then define three functions to return the id, first name and last name.

pub fn id(student: &Student) -> u32 {
}

pub fn first_name(student: &Student) -> String {
}

pub fn last_name(student: &Student) -> String {
}

Usage

Here is a program to test your functions

use tuples_refs::*;

fn main() {
	let student = Student(20, "Pedro".to_string(), "Domingos".to_string());
	println!("Student: {:?}", student);
	println!("Student first name: {}", first_name(&student));
	println!("Student last name: {}", last_name(&student));
	println!("Student Id: {}", id(&student));
}

And its output:

$ cargo run
Student: Student(20, "Pedro", "Domingos")
Student first name: Pedro
Student last name: Domingos
Student Id: 20
$

Notions