Skip to content

Commit

Permalink
quiz3 for generics and traits
Browse files Browse the repository at this point in the history
  • Loading branch information
rganesan committed May 16, 2024
1 parent a643951 commit 36eadf1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions exercises/quiz3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
//
// Execute `rustlings hint quiz3` or use the `hint` watch subcommand for a hint.

// I AM NOT DONE

pub struct ReportCard {
pub grade: f32,
pub struct ReportCard<T> {
pub grade: T,
pub student_name: String,
pub student_age: u8,
}

impl ReportCard {
impl<T: std::fmt::Display> ReportCard<T> {
pub fn print(&self) -> String {
format!("{} ({}) - achieved a grade of {}",
&self.student_name, &self.student_age, &self.grade)
Expand All @@ -50,9 +48,8 @@ mod tests {

#[test]
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+",
student_name: "Gary Plotter".to_string(),
student_age: 11,
};
Expand Down

0 comments on commit 36eadf1

Please sign in to comment.