/// Create a new `CanteenPicker` object.
///
/// This function panics if the given canteens list is empty.
Create a new `CanteenPicker` object.
This function panics if the given canteens list is empty.
Create a new ` CanteenPicker ` object . This function panics if the given canteens list is empty .
fn new<T, I>(canteens: T) -> Self
    where
        T: IntoIterator<Item = Canteen, IntoIter = I>,
        I: Iterator<Item = Canteen>,
    {
        let canteens: Vec<_> = canteens.into_iter().collect();
        assert!(!canteens.is_empty());
        let mut weight_sums = Vec::with_capacity(canteens.len());
        let mut weight_sum = 0u64;
        for i in &canteens {
            weight_sum += i.weight;
            weight_sums.push(weight_sum);
        }
        Self {
            canteens,
            weight_sums,
            weight_sum,
        }
    }
fn new < T , I > ( canteens : T ) -> Self where T : IntoIterator < Item = Canteen , IntoIter = I > , I : Iterator < Item = Canteen > , { let canteens : Vec < _ > = canteens . into_iter ( ) . collect ( ) ; assert ! ( canteens is_empty ( ) ) ; let mut weight_sums = Vec :: with_capacity ( canteens . len ( ) ) ; let mut weight_sum = 0u64 ; for i in & canteens { weight_sum += i . weight ; weight_sums . push ( weight_sum ) ; } Self { canteens , weight_sums , weight_sum , } }
Create a new `CanteenPicker` object.
Create a new ` CanteenPicker ` object .
canteens
T