fn find_region(&mut self, size: usize, align: usize) -> Option<(&'static mut ListNode, usize)> {
        //current node
        let mut current = &mut self.head;

        //iterate through the list, while there are tail Nodes
        while let Some(ref mut region) = current.next {
            if let Ok(alloc_start) = Self::alloc_from_region(&region, size, align) {
                // this region will do for allocation, remove it from the list
                let next_next = region.next.take(); // clear it's tail
                let res = Some((current.next.take().unwrap(), alloc_start));
                current.next = next_next; // from A -> B -> C to  A -> C
                return res;
            } else {
                //region won't work, move to next in the list
                current = current.next.as_mut().unwrap()
            }
        }
        //no region found
        None
    }
//Looks for a free region with a given size and alignment and removes it from the list
Looks for a free region with a given size and alignment and removes it from the list
Looks for a free region with a given size and alignment and removes it from the list
fn find_region(&mut self, size: usize, align: usize) -> Option<(&'static mut ListNode, usize)> {
        //current node
        let mut current = &mut self.head;
        //iterate through the list, while there are tail Nodes
        while let Some(ref mut region) = current.next {
            if let Ok(alloc_start) = Self::alloc_from_region(&region, size, align) {
                // this region will do for allocation, remove it from the list
                let next_next = region.next.take(); // clear it's tail
                let res = Some((current.next.take().unwrap(), alloc_start));
                current.next = next_next; // from A -> B -> C to  A -> C
                return res;
            } else {
                //region won't work, move to next in the list
                current = current.next.as_mut().unwrap()
            }
        }
        //no region found
        None
    }
fn find_region ( & mut self , size : usize , align : usize ) -> Option < ( & ' static mut ListNode , usize ) > { //current node let mut current = & mut self . head ; //iterate through the list, while there are tail Nodes while let Some ( ref mut region ) = current . next { if let Ok ( alloc_start ) = Self :: alloc_from_region ( & region , size , align ) { // this region will do for allocation, remove it from the list let next_next = region . next . take ( ) ; // clear it's tail let res = Some ( ( current . next . take ( ) . unwrap ( ) , alloc_start ) ) ; current . next = next_next ; // from A -> B -> C to  A -> C return res ; } else { //region won't work, move to next in the list current = current . next . as_mut ( ) . unwrap ( ) } } //no region found None }
Looks for a free region with a given size and alignment and removes it from the list
Looks for a free region with a given size and alignment and removes it from the list
&mut self
size
usize
align
usize
&mut self
size
usize
align
usize