permutohedron icon indicating copy to clipboard operation
permutohedron copied to clipboard

Allow giving ownership of slice to Heap

Open hellow554 opened this issue 7 years ago • 0 comments
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.

hellow554 avatar Sep 26 '18 20:09 hellow554