We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0152ed7 commit 40aa09aCopy full SHA for 40aa09a
tools/witx/src/layout.rs
@@ -125,7 +125,22 @@ mod test {
125
126
impl UnionDatatype {
127
pub fn layout(&self, cache: &mut HashMap<TypeRef, SizeAlign>) -> SizeAlign {
128
- unimplemented!()
+ let sas = self
129
+ .variants
130
+ .iter()
131
+ .map(|v| v.tref.layout(cache))
132
+ .collect::<Vec<SizeAlign>>();
133
+ let size = sas
134
135
+ .map(|sa| sa.size)
136
+ .max()
137
+ .expect("nonzero variants");
138
+ let align = sas
139
140
+ .map(|sa| sa.align)
141
142
143
+ SizeAlign { size, align }
144
}
145
146
0 commit comments