I am very new to rust, (still working my way through the book) and am re-writing a DNA searching algorithm I wrote in node.js in rust. Each error I've gotten so far I've been able to get through except this one. I am trying to write a function that takes a DNA sequence and a 3-letter flag, and returns all indexes where that flag is found in the input sequence.
fn get_termination_flag_indices (input_sequence: String, flag: String) -> Vec<(usize, &'static str)> {
let flag_indices: Vec<_> = input_sequence.match_indices(&flag).into_iter().collect();
println!("{:?}", flag_indices);
flag_indices
}
I haven't been able to make sense of the error I'm receiving:
returns a value referencing data owned by the current function
I understand from a very high level what it's telling me, but I don't know how to fix it. Honestly I'm just not far enough along to really grasp what's going on here. Any help explaining what's going on under the hood would be extremely helpful.