-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.rs
More file actions
48 lines (31 loc) · 1.05 KB
/
Copy pathtest2.rs
File metadata and controls
48 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// test2.rs
// This is a test for the following sections:
// - Strings
// Ok, here are a bunch of values-- some are `Strings`, some are `&strs`. 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!
fn string_slice(arg: &str) {
println!("{}", arg);
}
fn string(arg: String) {
println!("{}", arg);
}
fn main() {
(string_slice("blue"));
(string("red".to_string()));
//string
(string(String::from("hi")));
(string("rust is fun!".to_owned()));
//string
(string("nice weather".into()));
(string_slice("nice weather".into()));
//this is a String
(string(format!("Interpolation {}", "Station")));
//Slice
(string_slice(&String::from("abc")[0..1]));
//Slice
(string_slice(" hello there ".trim()));
(string("Happy Monday!".to_string().replace("Mon", "Tues")));
(string("mY sHiFt KeY iS sTiCkY".to_lowercase()));
}