Skip to content

Commit e91303c

Browse files
committed
Implement EnvLen + Index
1 parent 0ac2984 commit e91303c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fathom/src/env.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
//! and [`SliceEnv`], but when we need to copy environments often, we use a
1818
//! [`SharedEnv`] to increase the amount of sharing at the expense of locality.
1919
20-
use std::{fmt, ops::Add};
20+
use std::fmt;
21+
use std::ops::Add;
2122

2223
/// Underlying variable representation.
2324
type RawVar = u16;
@@ -133,6 +134,13 @@ pub fn levels() -> impl Iterator<Item = Level> {
133134
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
134135
pub struct EnvLen(RawVar);
135136

137+
impl Add<Index> for EnvLen {
138+
type Output = Self;
139+
fn add(self, rhs: Index) -> Self::Output {
140+
Self(self.0 + rhs.0) // FIXME: check overflow?
141+
}
142+
}
143+
136144
impl EnvLen {
137145
/// Construct a new, empty environment.
138146
pub fn new() -> EnvLen {

0 commit comments

Comments
 (0)