Skip to content

Commit

Permalink
Name the fields of the Quantified struct
Browse files Browse the repository at this point in the history
Summary: Names the fields for readability, in preparation for adding a new "name" field.

Reviewed By: ndmitchell

Differential Revision: D66523863

fbshipit-source-id: ff8f1827470b723434c03b8cbd3e3112df8ece88
  • Loading branch information
rchen152 authored and facebook-github-bot committed Nov 27, 2024
1 parent f3402bf commit d0769ce
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pyre2/pyre2/bin/types/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ impl Var {
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Quantified(Unique, QuantifiedKind);
pub struct Quantified {
unique: Unique,
kind: QuantifiedKind,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum QuantifiedKind {
Expand All @@ -67,13 +70,16 @@ pub enum QuantifiedKind {

impl Display for Quantified {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "?{}", self.0)
write!(f, "?{}", self.unique)
}
}

impl Quantified {
pub fn new(uniques: &UniqueFactory, kind: QuantifiedKind) -> Self {
Quantified(uniques.fresh(), kind)
Quantified {
unique: uniques.fresh(),
kind,
}
}

pub fn type_var(uniques: &UniqueFactory) -> Self {
Expand All @@ -93,15 +99,15 @@ impl Quantified {
}

pub fn is_param_spec(&self) -> bool {
matches!(self.1, QuantifiedKind::ParamSpec)
matches!(self.kind, QuantifiedKind::ParamSpec)
}

pub fn id(&self) -> Unique {
self.0
self.unique
}

pub fn zero(&mut self) {
self.0 = Unique::zero();
self.unique = Unique::zero();
}
}

Expand Down

0 comments on commit d0769ce

Please sign in to comment.