mirror of
https://github.com/notohh/rustlings.git
synced 2024-12-23 03:38:09 -05:00
feat: move quiz2 to be strings4
This commit is contained in:
parent
ab8572e15b
commit
f443f4e7b3
2 changed files with 37 additions and 3 deletions
29
exercises/strings/strings4.rs
Normal file
29
exercises/strings/strings4.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// strings4.rs
|
||||
|
||||
// Ok, here are a bunch of values-- some are `String`s, some are `&str`s. Your
|
||||
// task is to call one of these two functions on each value depending on what
|
||||
// you think each value is. That is, add either `string_slice` or `string`
|
||||
// before the parentheses on each line. If you're right, it will compile!
|
||||
// No hints this time!
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
fn string_slice(arg: &str) {
|
||||
println!("{}", arg);
|
||||
}
|
||||
fn string(arg: String) {
|
||||
println!("{}", arg);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
???("blue");
|
||||
???("red".to_string());
|
||||
???(String::from("hi"));
|
||||
???("rust is fun!".to_owned());
|
||||
???("nice weather".into());
|
||||
???(format!("Interpolation {}", "Station"));
|
||||
???(&String::from("abc")[0..1]);
|
||||
???(" hello there ".trim());
|
||||
???("Happy Monday!".to_string().replace("Mon", "Tues"));
|
||||
???("mY sHiFt KeY iS sTiCkY".to_lowercase());
|
||||
}
|
11
info.toml
11
info.toml
|
@ -167,7 +167,7 @@ For that first compiler error, it's important in Rust that each conditional
|
|||
block returns the same type! To get the tests passing, you will need a couple
|
||||
conditions checking different input values."""
|
||||
|
||||
# TEST 1
|
||||
# QUIZ 1
|
||||
|
||||
[[exercises]]
|
||||
name = "quiz1"
|
||||
|
@ -454,6 +454,12 @@ them!
|
|||
For the compose_me method: You can either use the `format!` macro, or convert the string
|
||||
slice into an owned string, which you can then freely extend."""
|
||||
|
||||
[[exercises]]
|
||||
name = "strings4"
|
||||
path = "exercises/strings/strings4.rs"
|
||||
mode = "compile"
|
||||
hint = "No hints this time ;)"
|
||||
|
||||
# MODULES
|
||||
|
||||
[[exercises]]
|
||||
|
@ -517,8 +523,7 @@ Hint 2: If there is already an entry for a given key, the value returned by `ent
|
|||
Learn more at https://doc.rust-lang.org/book/ch08-03-hash-maps.html#updating-a-value-based-on-the-old-value
|
||||
"""
|
||||
|
||||
|
||||
# TEST 2
|
||||
# QUIZ 2
|
||||
|
||||
[[exercises]]
|
||||
name = "quiz2"
|
||||
|
|
Loading…
Reference in a new issue