fn main() {
let strings = vec![String::from("hello")];
let default = String::from("default");
let s = first_or(&strings, &default);
println!("{}", s);
}
fn first_or(strings: &Vec<String>, default: &String) -> &String {
if strings.len() > 0 {
&strings[0]
} else {
default
}
}
I tried to just either return &string[0] or default, but the error persisted. I dont want how to solve this error, but what specific part of this code is causing it and why?
1