pub fn allocidx(&mut self, init: T) -> Result<usize, T> {
        let idx = self.freelist;

        if idx != -1 {
            self.freelist = match self.pool[idx as usize] {
                Slot::Free(fl) => fl,
                _ => panic!("idx {} not free", idx),
            };
            self.pool[idx as usize] = Slot::Alloc(init);
            self.used += 1;
            Ok(idx as usize)
        } else {
            Err(init)
        }
    }
/// Allocate an index in the pool. Returns None if the Pool is all used.
Allocate an index in the pool. Returns None if the Pool is all used.
Allocate an index in the pool . Returns None if the Pool is all used .
pub fn allocidx(&mut self, init: T) -> Result<usize, T> {
        let idx = self.freelist;
        if idx != -1 {
            self.freelist = match self.pool[idx as usize] {
                Slot::Free(fl) => fl,
                _ => panic!("idx {} not free", idx),
            };
            self.pool[idx as usize] = Slot::Alloc(init);
            self.used += 1;
            Ok(idx as usize)
        } else {
            Err(init)
        }
    }
pub fn allocidx ( & mut self , init : T ) -> Result < usize , T > { let idx = self . freelist ; if idx != - 1 { self . freelist = match self . pool [ idx as usize ] { Slot :: Free ( fl ) => fl , _ => panic ! ( " " idx ) , } ; self . pool [ idx as usize ] = Slot :: Alloc ( init ) ; self . used += 1 ; Ok ( idx as usize ) } else { Err ( init ) } }
Allocate an index in the pool.
Allocate an index in the pool .
&mut self
init
T
&mut self
init
T