mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-04 01:39:18 +00:00
Fix string manipulation functions
This commit is contained in:
parent
c0768cc4da
commit
13c442ec31
@ -3,21 +3,23 @@
|
||||
// Execute `rustlings hint strings3` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
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's multiple ways to do this!
|
||||
???
|
||||
let mut s = String::new();
|
||||
s.push_str(input);
|
||||
s.push_str(" world!");
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
fn replace_me(input: &str) -> String {
|
||||
// TODO: Replace "cars" in the string with "balloons"!
|
||||
???
|
||||
input.replace("cars", "balloons")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user