Skip to main content

budget

Function budget 

Source
pub fn budget<Item, Iter, Size>(
    items: Iter,
    limit: usize,
    size: Size,
) -> impl Iterator<Item = Result<Item, Item>>
where Iter: IntoIterator<Item = Item>, Size: Fn(&Item) -> usize,
Expand description

Marks each item, in order, Ok while its size fits within limit together with the items kept before it, and Err otherwise.

An item that does not fit is skipped rather than ending the walk, so a later smaller item may still be kept. The selection depends only on the sizes and their order.