forked from M-Labs/nac3
core: Move Type impl block directly below type declaration
This commit is contained in:
parent
91e3824517
commit
c78accce70
@ -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<DefinitionId> {
|
||||
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<DefinitionId> {
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user