1
Fork 0

offset_of

This commit is contained in:
DrMeepster 2022-09-11 00:37:49 -07:00
parent b92a41c676
commit 511e457c4b
71 changed files with 841 additions and 38 deletions

View file

@ -124,6 +124,21 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
{
Ty::is_unit(self)
}
pub fn offset_of_subfield<C>(self, cx: &C, indices: impl Iterator<Item = usize>) -> Size
where
Ty: TyAbiInterface<'a, C>,
{
let mut layout = self;
let mut offset = Size::ZERO;
for index in indices {
offset += layout.fields.offset(index);
layout = layout.field(cx, index);
}
offset
}
}
impl<'a, Ty> TyAndLayout<'a, Ty> {