Skip to content

Commit

Permalink
Merge pull request #16 from Joaopmorais/Quiz3
Browse files Browse the repository at this point in the history
quiz 3
  • Loading branch information
Joaopmorais committed Feb 20, 2024
2 parents 03d44f4 + f13fc1b commit 05b9a11
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions exercises/quiz3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
//
// 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> {
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)
Expand All @@ -34,7 +35,7 @@ impl ReportCard {
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn generate_numeric_report_card() {
let report_card = ReportCard {
Expand All @@ -52,7 +53,7 @@ mod tests {
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 05b9a11

Please sign in to comment.