From efcfa37634fc1762d279d256682f6c288fc7fb54 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 20 Mar 2021 01:21:21 -0400 Subject: [PATCH] Implement Index for Layouter --- src/proc/layouter.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/proc/layouter.rs b/src/proc/layouter.rs index 280305bcd4..697d119d95 100644 --- a/src/proc/layouter.rs +++ b/src/proc/layouter.rs @@ -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) -> TypeLayout { - self.layouts[handle.index()] +impl ops::Index> for Layouter { + type Output = TypeLayout; + fn index(&self, handle: Handle) -> &TypeLayout { + &self.layouts[handle.index()] } }