blob: 413c759d8683d783240a79ceb1f910454ab31117 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
use crate::syntax::Label;
// Exactly like a Label, but equality returns always true.
// This is so that NirKind equality is exactly alpha-equivalence.
#[derive(Clone, Eq)]
pub struct Binder {
name: Label,
}
impl Binder {
pub(crate) fn new(name: Label) -> Self {
Binder { name }
}
pub(crate) fn to_label(&self) -> Label {
self.clone().into()
}
}
/// Equality up to alpha-equivalence
impl std::cmp::PartialEq for Binder {
fn eq(&self, _other: &Self) -> bool {
true
}
}
impl std::fmt::Debug for Binder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Binder({})", &self.name)
}
}
impl From<Binder> for Label {
fn from(x: Binder) -> Label {
x.name
}
}
|