diff --git a/nac3core/src/typecheck/typedef/mod.rs b/nac3core/src/typecheck/typedef/mod.rs index 97c9483c..6c2ffbc5 100644 --- a/nac3core/src/typecheck/typedef/mod.rs +++ b/nac3core/src/typecheck/typedef/mod.rs @@ -22,6 +22,19 @@ mod test; /// Handle for a type, implemented as a key in the unification table. pub type Type = UnificationKey; +impl Type { + /// Wrapper function for cleaner code so that we don't need to write this long pattern matching + /// just to get the field `obj_id`. + #[must_use] + pub fn obj_id(self, unifier: &Unifier) -> Option { + if let TypeEnum::TObj { obj_id, .. } = &*unifier.get_ty_immutable(self) { + Some(*obj_id) + } else { + None + } + } +} + #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct CallId(pub(super) usize); @@ -109,19 +122,6 @@ pub enum RecordKey { Int(i32), } -impl Type { - /// Wrapper function for cleaner code so that we don't need to write this long pattern matching - /// just to get the field `obj_id`. - #[must_use] - pub fn obj_id(self, unifier: &Unifier) -> Option { - if let TypeEnum::TObj { obj_id, .. } = &*unifier.get_ty_immutable(self) { - Some(*obj_id) - } else { - None - } - } -} - impl From<&RecordKey> for StrRef { fn from(r: &RecordKey) -> Self { match r {