mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-12 05:39:19 +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.
|
// 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"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user