Implement Index for Layouter

This commit is contained in:
Dzmitry Malyshau
2021-03-20 01:21:21 -04:00
parent c992e638fe
commit efcfa37634

View File

@@ -1,4 +1,4 @@
use crate::arena::Arena;
use crate::arena::{Arena, Handle};
use std::{num::NonZeroU32, ops};
pub type Alignment = NonZeroU32;
@@ -130,8 +130,11 @@ impl Layouter {
});
}
}
}
pub fn resolve(&self, handle: crate::Handle<crate::Type>) -> TypeLayout {
self.layouts[handle.index()]
impl ops::Index<Handle<crate::Type>> for Layouter {
type Output = TypeLayout;
fn index(&self, handle: Handle<crate::Type>) -> &TypeLayout {
&self.layouts[handle.index()]
}
}