Rust - need vector slices to live longer :      13 fn populate_chain(file_path: &str) -> HashMap<String, HashSet<& String>>{
     14     println!("loading...");
     15     let time = util::StopWatch::new();
     16     let mut words = HashMap::new();
     17     {
     18         let f = |mut x:Vec<String>|{
     19             let word = x.pop().unwrap();
     20             words.insert(word, HashSet::new());
     21         };
     22         Csv::process_rows(f, file_path, "\t");
     23     }
     24 
     25     let col: Vec<(String, HashSet<& String>)> = words.clone().into_iter().collect();
     26     let m: usize = col.len()-1;
     27     for i in 0..m{
     28     ¦   let ref k: String = col[i].0;
     29     ¦   for j in i..m{
     30     ¦   ¦   let ref nk: String = col[j].0;
     31     ¦   ¦   if check_link(k, nk){
     32     ¦   ¦   ¦   words.get_mut(k).unwrap().insert(nk);
     33     ¦   ¦   ¦   words.get_mut(nk).unwrap().insert(k);
     34     ¦   ¦   }
     35     ¦   }
     36     }
     37 
     38     time.print_time();
     39     words
     40 }

Is there any way to get the slices of this vector to last long enough so that I can use them in this kind of circular structure?

I'm basically just using the double four loops to chain words together which are related so that they can be quickly looked up later.

Here are the compiler errors...

    error: `col` does not live long enough
      --> src/main.rs:28:29
       |
    28 |         let ref k: String = col[i].0;
       |                             ^^^ does not live long enough
    ...
    40 | }
       | - borrowed value only lives until here
       |
    note: borrowed value must be valid for the anonymous lifetime #1 defined on the block at 13:72...
      --> src/main.rs:13:73
       |
    13 | fn populate_chain(file_path: &str) -> HashMap<String, HashSet<& String>>{
       |                                                                         ^
    
    error: `col` does not live long enough
      --> src/main.rs:30:34
       |
    30 |             let ref nk: String = col[j].0;
       |                                  ^^^ does not live long enough
    ...
    40 | }
       | - borrowed value only lives until here
       |
    note: borrowed value must be valid for the anonymous lifetime #1 defined on the block at 13:72...
      --> src/main.rs:13:73
       |
    13 | fn populate_chain(file_path: &str) -> HashMap<String, HashSet<& String>>{
       |  

                                                                     