feat: quiz3 done of traits and generics

This commit is contained in:
2026-09-11 17:38:14 +02:00
parent 8ded4cc8b5
commit 3f32906547
+4 -4
View File
@@ -12,18 +12,18 @@
// block to support alphabetical report cards in addition to numerical ones. // block to support alphabetical report cards in addition to numerical ones.
// TODO: Adjust the struct as described above. // TODO: Adjust the struct as described above.
struct ReportCard { struct ReportCard<T> {
grade: f32, grade: T,
student_name: String, student_name: String,
student_age: u8, student_age: u8,
} }
// TODO: Adjust the impl block as described above. // TODO: Adjust the impl block as described above.
impl ReportCard { impl<T: std::fmt::Display> ReportCard<T> {
fn print(&self) -> String { fn print(&self) -> String {
format!( format!(
"{} ({}) - achieved a grade of {}", "{} ({}) - achieved a grade of {}",
&self.student_name, &self.student_age, &self.grade, self.student_name, self.student_age, self.grade,
) )
} }
} }