Index into constraining via trait

This commit is contained in:
Ayaz Hafiz 2022-11-07 17:07:58 -06:00
parent 24b6d4a3a9
commit 51d813dae2
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 25 additions and 9 deletions

View file

@ -676,6 +676,22 @@ impl Constraints {
roc_error_macros::assert_sizeof_default!(Constraint, 3 * 8);
roc_error_macros::assert_sizeof_aarch64!(Constraint, 3 * 8);
impl std::ops::Index<ExpectedTypeIndex> for Constraints {
type Output = Expected<TypeOrVar>;
fn index(&self, index: ExpectedTypeIndex) -> &Self::Output {
&self.expectations[index.index()]
}
}
impl std::ops::Index<PExpectedTypeIndex> for Constraints {
type Output = PExpected<TypeOrVar>;
fn index(&self, index: PExpectedTypeIndex) -> &Self::Output {
&self.pattern_expectations[index.index()]
}
}
#[derive(Clone, Copy, Debug)]
pub struct Eq(
pub TypeOrVar,