pub fn extend<I>(&mut self, dl: &TargetDataLayout,
                     fields: I,
                     scapegoat: Ty<'gcx>)
                     -> Result<(), LayoutError<'gcx>>
    where I: Iterator<Item=Result<&'a Layout, LayoutError<'gcx>>> {
        self.offset_after_field.reserve(fields.size_hint().0);

        for field in fields {
            if !self.sized {
                bug!("Struct::compute: field #{} of `{}` comes after unsized field",
                     self.offset_after_field.len(), scapegoat);
            }

            let field = field?;
            if field.is_unsized() {
                self.sized = false;
            }

            // Invariant: offset < dl.obj_size_bound() <= 1<<61
            let mut offset = if !self.packed {
                let align = field.align(dl);
                self.align = self.align.max(align);
                self.offset_after_field.last_mut().map_or(Size::from_bytes(0), |last| {
                    *last = last.abi_align(align);
                    *last
                })
            } else {
                self.offset_after_field.last().map_or(Size::from_bytes(0), |&last| last)
            };

            offset = offset.checked_add(field.size(dl), dl)
                           .map_or(Err(LayoutError::SizeOverflow(scapegoat)), Ok)?;

            self.offset_after_field.push(offset);
        }

        Ok(())
    }
/// Extend the Struct with more fields.
Extend the Struct with more fields.
Extend the Struct with more fields .
pub fn extend<I>(&mut self, dl: &TargetDataLayout,
                     fields: I,
                     scapegoat: Ty<'gcx>)
                     -> Result<(), LayoutError<'gcx>>
    where I: Iterator<Item=Result<&'a Layout, LayoutError<'gcx>>> {
        self.offset_after_field.reserve(fields.size_hint().0);
        for field in fields {
            if !self.sized {
                bug!("Struct::compute: field #{} of `{}` comes after unsized field",
                     self.offset_after_field.len(), scapegoat);
            }
            let field = field?;
            if field.is_unsized() {
                self.sized = false;
            }
            // Invariant: offset < dl.obj_size_bound() <= 1<<61
            let mut offset = if !self.packed {
                let align = field.align(dl);
                self.align = self.align.max(align);
                self.offset_after_field.last_mut().map_or(Size::from_bytes(0), |last| {
                    *last = last.abi_align(align);
                    *last
                })
            } else {
                self.offset_after_field.last().map_or(Size::from_bytes(0), |&last| last)
            };
            offset = offset.checked_add(field.size(dl), dl)
                           .map_or(Err(LayoutError::SizeOverflow(scapegoat)), Ok)?;
            self.offset_after_field.push(offset);
        }
        Ok(())
    }
pub fn extend < I > ( & mut self , dl : & TargetDataLayout , fields : I , scapegoat : Ty < ' gcx > ) -> Result < ( ) , LayoutError < ' gcx > > where I : Iterator < Item = Result < & ' a Layout , LayoutError < ' gcx > > > { self . offset_after_field . reserve ( fields . size_hint ( ) . 0 ) ; for field in fields { if ! self . sized { bug ! ( " " self offset_after_field len ( ) scapegoat ) ; } let field = field ? ; if field . is_unsized ( ) { self . sized = false ; } // Invariant: offset < dl.obj_size_bound() <= 1<<61 let mut offset = if ! self . packed { let align = field . align ( dl ) ; self . align = self . align . max ( align ) ; self . offset_after_field . last_mut ( ) . map_or ( Size :: from_bytes ( 0 ) , | last | { * last = last . abi_align ( align ) ; * last } ) } else { self . offset_after_field . last ( ) . map_or ( Size :: from_bytes ( 0 ) , | & last | last ) } ; offset = offset . checked_add ( field . size ( dl ) , dl ) . map_or ( Err ( LayoutError :: SizeOverflow ( scapegoat ) ) , Ok ) ? ; self . offset_after_field . push ( offset ) ; } Ok ( ( ) ) }
Extend the Struct with more fields.
Extend the Struct with more fields .
&mut self
dl
&TargetDataLayout
fields
I
scapegoat
Ty<'gcx>
&mut self
dl
&TargetDataLayout
fields
I
scapegoat
Ty<'gcx>