strings and modules

This commit is contained in:
2026-01-25 15:49:17 +00:00
parent 26f785a0ff
commit 82f597d052
5 changed files with 20 additions and 18 deletions

View File

@@ -1,13 +1,15 @@
fn trim_me(input: &str) -> &str {
// TODO: Remove whitespace from both ends of a string.
input.trim()
}
fn compose_me(input: &str) -> String {
// TODO: Add " world!" to the string! There are multiple ways to do this.
let mut tmp = input.to_string();
tmp.push_str(" world!");
tmp
}
fn replace_me(input: &str) -> String {
// TODO: Replace "cars" in the string with "balloons".
input.replace("cars", "balloons")
}
fn main() {