I am trying to use the permutohedron package and I ran into some issues with borrowing. This minimal example of how to use the package will likely be enough to understand my issue:
use permutohedron::Heap;
let mut data = vec![1, 2, 3];
let heap = Heap::new(&mut data);
I want to put both data and heap into the same structure and let a function return it, but I cannot figure out a way to do it. I would think something like this should be possible lifetime-wise, since the heap cannot outlive the data.
I am not allowed to use data anymore once heap is still in the scope, which is probably what causes my attempts to not compile. Is there some way to put data in the struct, but make it inaccessible?