title: using BufReader reading files line by line, stored into an array
body: <p>in the code below the creation of the string buffer 
  is a quickest way i have found as there's no allocation deallocation done 
  if i understand correctly</p>
  
  
  
  <pre class="lang-rust prettyprint-override"><code>pub extern fn rust_print_file() -&gt; *mut PackChar {
  
      //set min size to 50 - avoid expanding when line count is 50 or less
      let mut out_vec = Vec::with_capacity(50);
      let mut curdr = env::current_dir().unwrap();//get path to file dir
      let fl_str = "file_test.txt";
      curdr.push(fl_str);//created full path to be used
  
      let file = BufReader::new(File::open(curdr).unwrap());
  
      //here i try to accommodate each line in a struct
  
      let mut line_index = 0;
      for line in file.lines() {
  
          let cur_line = line.unwrap();
  
          let loclbuf_size = cur_line.len();
          let mut loclbuf = String::with_capacity(buffer_size);
          //i tried two ways
          loclbuf.push_str(cur_line.unwrap()); // can't be done
          loclbuf.push_str(line.unwrap()); // can't be done too
  
          let pack_char = PackChar {
              int_val: line_index,
              buffer_size: loclbuf_size as i32,
              buffer: loclbuf.as_ptr() as *mut _,
          };
          line_index+=1;
          mem::forget(buffer);
          out_vec.push(pack_char);
      }
      Box::into_raw(out_vec.into_boxed_slice()) as *mut _ 
  }
  </code></pre>
  
  <p>this is the struct i am using to pass to C# </p>
  
  <pre class="lang-rust prettyprint-override"><code>#[repr(C)]
  pub struct PackChar {
      pub int_val: c_int,
      pub buffer: *mut c_char,
      pub buffer_size: c_int,
  }
  </code></pre>
  
  <p>when generating some dummy text 
  i have checked, and it passes data correctly to "the other side" to use it.
  but not with the read line task, produced text as coded above.</p>
  
  <p>and this is another way i have tried, although i prefer the above code but this one  throws a compile error.</p>
  
  <p>error: use of moved value: <code>buffer</code> [E0382] on <code>forget(buffer)</code></p>
  
  <pre class="lang-rust prettyprint-override"><code>#[no_mangle]
  pub extern fn rust_return_file_read_lines() -&gt; *mut PackChar {
      let mut out_vec = Vec::with_capacity(50);
  
      let mut curdr = env::current_dir().unwrap();
      let fl_str = "file_test.txt";
      curdr.push(fl_str);
  
  
      let file = BufReader::new(File::open(curdr).unwrap());
  
      let mut lindex = 0;
      for line in file.lines() {
  
         let tmpbuffer = line.unwrap().into_bytes();
         let tmpbuffer_size = buffer.len();
  
         let pack_char = PackChar {
             int_val: lindex,
             buffer_size: tmpbuffer_size as i32,
             buffer: Box::into_raw(tmpbuffer.into_boxed_slice()) as *mut _
         };
         lindex+=1;
         mem::forget(buffer);
         out_vec.push(pack_char);
  
      }
      Box::into_raw(out_vec.into_boxed_slice()) as *mut _
  }
  </code></pre>
  
  <p><strong>Edit</strong>
  as long as the type of buffer :</p>
  
  <p><code>buffer: loclbuf.as_ptr() as *mut _,</code></p>
  
  <p>i could pass the the data correctly to c#. 
  so <strong>how could i read lines that way so each will be stored into buffer as described ?</strong></p>