pub fn restore_string(s: String, indices: Vec<i32>) -> String {
let mut res_arr_str = vec![""; s.len()]; // 1
let mut res_arr_char = vec![' '; s.len()]; //2
let mut res_arr_string = vec!["".to_string(); s.len()]; // 3
s.char_indices().for_each(move |(index, ch)| {
res_arr_str[indices[index] as usize] = &ch.to_string();
res_arr_char[indices[index] as usize] = ch;
res_arr_string[indices[index] as usize] = ch.to_string();
});
res_arr_char.into_iter().collect()
}
i do not understand why 1 is error,but 2 and 3 not,which basic knowlodge i have not understand,which concept