mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-12 21:59:18 +00:00
quiz
This commit is contained in:
parent
1df10aa893
commit
825b0e99da
@ -14,18 +14,19 @@
|
||||
|
||||
// Execute `rustlings hint quiz3` or use the `hint` watch subcommand for a hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
pub struct ReportCard {
|
||||
pub grade: f32,
|
||||
use std::fmt::Display;
|
||||
pub struct ReportCard<T: Display> {
|
||||
pub grade: T,
|
||||
pub student_name: String,
|
||||
pub student_age: u8,
|
||||
}
|
||||
|
||||
impl ReportCard {
|
||||
impl<T: Display> ReportCard<T> {
|
||||
pub fn print(&self) -> String {
|
||||
format!("{} ({}) - achieved a grade of {}",
|
||||
&self.student_name, &self.student_age, &self.grade)
|
||||
format!(
|
||||
"{} ({}) - achieved a grade of {}",
|
||||
&self.student_name, &self.student_age, &self.grade
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +57,7 @@ mod tests {
|
||||
};
|
||||
assert_eq!(
|
||||
report_card.print(),
|
||||
"Gary Plotter (11) - achieved a grade of A+"
|
||||
"Gary Plotter (11) - achieved a grade of 2.1"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user