mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
Make Rank opaque
This commit is contained in:
parent
4165e61950
commit
978f498455
1 changed files with 31 additions and 2 deletions
33
src/subs.rs
33
src/subs.rs
|
@ -177,10 +177,39 @@ fn unnamed_flex_var() -> Content {
|
||||||
Content::FlexVar(None)
|
Content::FlexVar(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct Rank(u8);
|
||||||
|
|
||||||
|
impl Rank {
|
||||||
|
pub fn none() -> Self {
|
||||||
|
Rank(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn outermost() -> Self {
|
||||||
|
Rank(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn next(&self) -> Self {
|
||||||
|
Rank(self.0 + 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<u8> for Rank {
|
||||||
|
fn into(self) -> u8 {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<usize> for Rank {
|
||||||
|
fn into(self) -> usize {
|
||||||
|
self.0 as usize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct Descriptor {
|
pub struct Descriptor {
|
||||||
pub content: Content,
|
pub content: Content,
|
||||||
pub rank: u8,
|
pub rank: Rank,
|
||||||
pub mark: Mark,
|
pub mark: Mark,
|
||||||
pub copy: Option<Variable>,
|
pub copy: Option<Variable>,
|
||||||
}
|
}
|
||||||
|
@ -195,7 +224,7 @@ impl From<Content> for Descriptor {
|
||||||
fn from(content: Content) -> Descriptor {
|
fn from(content: Content) -> Descriptor {
|
||||||
Descriptor {
|
Descriptor {
|
||||||
content,
|
content,
|
||||||
rank: 0,
|
rank: Rank::none(),
|
||||||
mark: Mark::none(),
|
mark: Mark::none(),
|
||||||
copy: None,
|
copy: None,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue