permutohedron
permutohedron copied to clipboard
Allow giving ownership of slice to Heap
trafficstars
Currently When I want something like
fn foo(a: &mut Vec<u8>) -> impl Iterator<Item=u8> {
Heap::new(&mut a).map(|h| 0)
}
it won't work, because it says, that a won't live long enough, so I have to do it like
fn foo(a: &mut Vec<u8>) -> impl Iterator<Item=u8> {
let heap = Heap::new(&mut a).collect::<Vec<_>>();
heap.into_iter().map(|h| 0)
}
which is ... meh. Either accepting a slice and hold an internal mutable buffer, or taking a slice as value and store it inside, but this &mut causes some trouble.