bluss / permutohedron

https://docs.rs/permutohedron/
Apache License 2.0
38 stars 5 forks source link

Allow giving ownership of slice to Heap #8

Open hellow554 opened 6 years ago

hellow554 commented 6 years ago

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.