From c78accce705a7f92c200567dcf084d5960565b14 Mon Sep 17 00:00:00 2001 From: David Mak Date: Tue, 25 Jun 2024 15:44:18 +0800 Subject: [PATCH] core: Move Type impl block directly below type declaration --- nac3core/src/typecheck/typedef/mod.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) 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 {