Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

answer of test2.rs? #1

Open
chyyuu opened this issue May 23, 2020 · 1 comment
Open

answer of test2.rs? #1

chyyuu opened this issue May 23, 2020 · 1 comment

Comments

@chyyuu
Copy link

chyyuu commented May 23, 2020

下面这个题目的正确答案是?

// 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!

// 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());
}

@xushanpu123
Copy link
Owner

xushanpu123 commented May 23, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants