/// Add the descriptor at an unused index, and return the index.
Add the descriptor at an unused index, and return the index.
Add the descriptor at an unused index and return the index .
pub fn add(&mut self, mut descriptor: CompatDescriptor) -> u32 {
        let idx = if let Some(idx) = self.available_indices.iter().next() {
            // Un-borrow from `available_indices`.
            let idx = *idx;
            // Take from `available_indices`
            trace!("Reusing available index {}", idx);
            self.available_indices.remove(&idx);
            idx
        } else {
            // Skip past any indexes that are in use. This can happen after
            // calling `set` with a value greater than `next_index`.
            while self.descriptors.contains_key(&self.next_index) {
                trace!("Skipping past in-use index {}", self.next_index);
                self.next_index += 1;
            }
            // Take the next index.
            let idx = self.next_index;
            trace!("Using index {}", idx);
            self.next_index += 1;
            idx
        };
        descriptor.set_handle(idx);
        let prev = self.descriptors.insert(idx, descriptor);
        debug_assert!(prev.is_none(), "Already a descriptor at {}", idx);
        idx
    }
pub fn add ( & mut self , mut descriptor : CompatDescriptor ) -> u32 { let idx = if let Some ( idx ) = self . available_indices . iter ( ) . next ( ) { // Un-borrow from `available_indices`. let idx = * idx ; // Take from `available_indices` trace ! ( " " idx ) ; self . available_indices . remove ( & idx ) ; idx } else { // Skip past any indexes that are in use. This can happen after // calling `set` with a value greater than `next_index`. while self . descriptors . contains_key ( & self . next_index ) { trace ! ( " " self next_index ) ; self . next_index += 1 ; } // Take the next index. let idx = self . next_index ; trace ! ( " " idx ) ; self . next_index += 1 ; idx } ; descriptor . set_handle ( idx ) ; let prev = self . descriptors . insert ( idx , descriptor ) ; debug_assert ! ( prev is_none ( ) " " idx ) ; idx }
Add the descriptor at an unused index, and return the index.
Add the descriptor at an unused index and return the index .
&mut self
descriptor
CompatDescriptor