From ab28f3593503f6ab99dbb8bd544236373092bf48 Mon Sep 17 00:00:00 2001 From: Justin Kelz Date: Sun, 1 May 2022 08:51:08 -0700 Subject: [PATCH] Finished Generics 3! --- exercises/generics/generics3.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/exercises/generics/generics3.rs b/exercises/generics/generics3.rs index 64dd9bc1..0000e9a3 100644 --- a/exercises/generics/generics3.rs +++ b/exercises/generics/generics3.rs @@ -10,15 +10,14 @@ // Execute 'rustlings hint generics3' for hints! -// I AM NOT DONE -pub struct ReportCard { - pub grade: f32, +pub struct ReportCard { // Tell the struct that ReportCard can have an arbitrary type T + pub grade: T, // specify that grade is of ambiguious type pub student_name: String, pub student_age: u8, } -impl ReportCard { +impl ReportCard { // Listen to the compiler for impl, and then implement an arbitrary ReportCard type T. pub fn print(&self) -> String { format!("{} ({}) - achieved a grade of {}", &self.student_name, &self.student_age, &self.grade) @@ -46,7 +45,7 @@ mod tests { fn generate_alphabetic_report_card() { // TODO: Make sure to change the grade here after you finish the exercise. let report_card = ReportCard { - grade: 2.1, + grade: "A+", // I actually forgot to modify Arry's grade! student_name: "Gary Plotter".to_string(), student_age: 11, };