Do String borrow better

This commit is contained in:
Dan Buch 2020-11-27 22:57:06 -05:00
parent e3122519df
commit ed83cd6b64
Signed by: meatballhat
GPG Key ID: 9685130D8B763EA7

View File

@ -11,7 +11,7 @@ fn main() {
command = arg;
continue;
}
_ => command_args.push(arg.as_str().to_string()),
_ => command_args.push(arg.clone()),
}
}
@ -21,7 +21,7 @@ fn main() {
eprintln!("ERROR: missing a value to convert");
process::exit(1);
}
temp_convert(command_args[0].as_str().to_string())
temp_convert(&command_args[0])
}
"fib" => {
if command_args.len() < 1 {
@ -58,7 +58,7 @@ fn redefine_x() {
println!("The value of x is: {}", x);
}
fn temp_convert(to_convert: String) {
fn temp_convert(to_convert: &String) {
let to_convert = to_convert.to_lowercase();
if to_convert.ends_with("c") {
let c: f32 = to_convert