Hi, I'm creating file explorer, something like mc, and I have an fn:
fn fill_table_with_items(a_table: &mut tableViewType, a_dir: &PathBuf)
Then, later in code I try to call it which gives me error saying that a_table needs to be mutable:
table.set_on_submit(move |siv: &mut Cursive, row: usize, index: usize| {
let value = siv
.call_on_name(a_name, move |a_table: &mut tableViewType| {//HERE I'm getting the error
/*But if I change it to (note the extra mut in front of a_tabe) then it works:
mut a_table: &mut tableViewType
*/
let path: String = a_table.borrow_item(index).unwrap().name.clone();
fill_table_with_items(&mut a_table, &std::path::PathBuf::from(path));
})
.unwrap();
So my question is:
Why do I have to write:
mut a_table: &mut tableViewType
My fn fill_table_with_items(a_table: &mut tableViewType, a_dir: &PathBuf)
takes a_table by &mut so I thought that passing it by &mut would be the correct way to do it which is not. Could somebody please explain that to me?
Thanks