1
Fork 0

Make index_by_increasing_offset return one item for primitives

This commit is contained in:
Scott McMurray 2024-05-11 15:26:49 -07:00
parent dcab06d7d2
commit 99213ae164
2 changed files with 8 additions and 12 deletions

View file

@ -1271,7 +1271,12 @@ impl<FieldIdx: Idx> FieldsShape<FieldIdx> {
}
}
(0..self.count()).map(move |i| match *self {
// Primitives don't really have fields in the way that structs do,
// but having this return an empty iterator for them is unhelpful
// since that makes them look kinda like ZSTs, which they're not.
let pseudofield_count = if let FieldsShape::Primitive = self { 1 } else { self.count() };
(0..pseudofield_count).map(move |i| match *self {
FieldsShape::Primitive | FieldsShape::Union(_) | FieldsShape::Array { .. } => i,
FieldsShape::Arbitrary { .. } => {
if use_small {