feat: only need to compare unique and index
This commit is contained in:
parent
b8c5c268d4
commit
cbea795f68
|
@ -66,12 +66,18 @@ pub enum Constant {
|
|||
/// A Name containing it's parsed textual representation
|
||||
/// and a unique id from string interning. The Name's text is
|
||||
/// interned during parsing.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Name {
|
||||
pub text: String,
|
||||
pub unique: Unique,
|
||||
}
|
||||
|
||||
impl PartialEq for Name {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.unique == other.unique
|
||||
}
|
||||
}
|
||||
|
||||
/// A unique id used for string interning.
|
||||
#[derive(Debug, Clone, PartialEq, Copy, Eq, Hash)]
|
||||
pub struct Unique(isize);
|
||||
|
@ -110,12 +116,18 @@ impl Display for Unique {
|
|||
/// Similar to `Name` but for Debruijn indices.
|
||||
/// `Name` is replaced by `NamedDebruijn` when converting
|
||||
/// program to it's debruijn form.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct NamedDeBruijn {
|
||||
pub text: String,
|
||||
pub index: DeBruijn,
|
||||
}
|
||||
|
||||
impl PartialEq for NamedDeBruijn {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.index == other.index
|
||||
}
|
||||
}
|
||||
|
||||
/// This is useful for decoding a on chain program into debruijn form.
|
||||
/// It allows for injecting fake textual names while also using Debruijn for decoding
|
||||
/// without having to loop through twice.
|
||||
|
|
Loading…
Reference in New Issue