This commit is contained in:
enforcer007 2022-11-13 14:32:51 +05:30
parent 1df10aa893
commit 825b0e99da

View File

@ -14,18 +14,19 @@
// Execute `rustlings hint quiz3` or use the `hint` watch subcommand for a hint. // Execute `rustlings hint quiz3` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE use std::fmt::Display;
pub struct ReportCard<T: Display> {
pub struct ReportCard { pub grade: T,
pub grade: f32,
pub student_name: String, pub student_name: String,
pub student_age: u8, pub student_age: u8,
} }
impl ReportCard { impl<T: Display> ReportCard<T> {
pub fn print(&self) -> String { pub fn print(&self) -> String {
format!("{} ({}) - achieved a grade of {}", format!(
&self.student_name, &self.student_age, &self.grade) "{} ({}) - achieved a grade of {}",
&self.student_name, &self.student_age, &self.grade
)
} }
} }
@ -56,7 +57,7 @@ mod tests {
}; };
assert_eq!( assert_eq!(
report_card.print(), report_card.print(),
"Gary Plotter (11) - achieved a grade of A+" "Gary Plotter (11) - achieved a grade of 2.1"
); );
} }
} }