feat: completed solutions

This commit is contained in:
2026-03-23 03:36:33 -04:00
parent 2279bea6f1
commit f568c094cb
65 changed files with 424 additions and 139 deletions
+16 -2
View File
@@ -27,7 +27,21 @@ mod my_module {
use super::Command;
// TODO: Complete the function as described above.
// pub fn transformer(input: ???) -> ??? { ??? }
pub fn transformer(input: Vec<(String, Command)>) -> Vec<String> {
let mut output: Vec<String> = Vec::new();
for (string, command) in input {
match command {
Command::Uppercase => output.push(string.to_uppercase()),
Command::Trim => output.push(string.trim().into()),
Command::Append(number_of_times_bar_will_be_added) => {
output.push(string + &"bar".repeat(number_of_times_bar_will_be_added))
}
}
}
output
}
}
fn main() {
@@ -37,8 +51,8 @@ fn main() {
#[cfg(test)]
mod tests {
// TODO: What do we need to import to have `transformer` in scope?
// use ???;
use super::Command;
use super::my_module::transformer;
#[test]
fn it_works() {
+4 -3
View File
@@ -10,16 +10,17 @@
//
// Make the necessary code changes in the struct `ReportCard` and the impl
// block to support alphabetical report cards in addition to numerical ones.
use std::fmt::Display;
// TODO: Adjust the struct as described above.
struct ReportCard {
grade: f32,
struct ReportCard<G: Display> {
grade: G,
student_name: String,
student_age: u8,
}
// TODO: Adjust the impl block as described above.
impl ReportCard {
impl<G: Display> ReportCard<G> {
fn print(&self) -> String {
format!(
"{} ({}) - achieved a grade of {}",