This commit is contained in:
2024-04-07 19:53:54 -04:00
parent 459c52137a
commit 64a7939eb7
43 changed files with 141 additions and 160 deletions

View File

@@ -7,17 +7,21 @@
fn trim_me(input: &str) -> String {
// TODO: Remove whitespace from both ends of a string!
???
input.trim().to_string()
}
fn compose_me(input: &str) -> String {
// TODO: Add " world!" to the string! There are multiple ways to do this!
???
let mut s = input.to_string();
s.push_str(" world!");
s
}
fn replace_me(input: &str) -> String {
// TODO: Replace "cars" in the string with "balloons"!
???
let s = input.to_string();
let s = s.replace("cars", "balloons");
s
}
#[cfg(test)]
@@ -39,7 +43,13 @@ mod tests {
#[test]
fn replace_a_string() {
assert_eq!(replace_me("I think cars are cool"), "I think balloons are cool");
assert_eq!(replace_me("I love to look at cars"), "I love to look at balloons");
assert_eq!(
replace_me("I think cars are cool"),
"I think balloons are cool"
);
assert_eq!(
replace_me("I love to look at cars"),
"I love to look at balloons"
);
}
}