Skip to content

Commit 9cd1cb0

Browse files
feat: moved to_range to to_vector for extended iteration capabilities
1 parent 2624722 commit 9cd1cb0

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

crates/intrinsic-test/src/common/constraint.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ use std::ops::Range;
55
pub enum Constraint {
66
Equal(i64),
77
Range(Range<i64>),
8+
Set(Vec<i64>),
89
}
910

1011
impl Constraint {
11-
pub fn to_range(&self) -> Range<i64> {
12+
pub fn to_vector(&self) -> Vec<i64> {
1213
match self {
13-
Constraint::Equal(eq) => *eq..*eq + 1,
14-
Constraint::Range(range) => range.clone(),
14+
Constraint::Equal(eq) => vec![*eq],
15+
Constraint::Range(range) => range.clone().collect::<Vec<i64>>(),
16+
Constraint::Set(values) => values.clone(),
1517
}
1618
}
1719
}

crates/intrinsic-test/src/common/gen_c.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ pub fn generate_c_constraint_blocks<T: IntrinsicTypeDefinition>(
128128
target: &str,
129129
) -> String {
130130
if let Some((current, constraints)) = constraints.split_last() {
131-
let range = current
132-
.constraint
133-
.iter()
134-
.map(|c| c.to_range())
135-
.flat_map(|r| r.into_iter());
131+
let range = current.constraint.iter().flat_map(|c| c.to_vector());
136132

137133
let body_indentation = indentation.nested();
138134
range

crates/intrinsic-test/src/common/gen_rust.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,7 @@ pub fn generate_rust_constraint_blocks<T: IntrinsicTypeDefinition>(
177177
name: String,
178178
) -> String {
179179
if let Some((current, constraints)) = constraints.split_last() {
180-
let range = current
181-
.constraint
182-
.iter()
183-
.map(|c| c.to_range())
184-
.flat_map(|r| r.into_iter());
180+
let range = current.constraint.iter().flat_map(|c| c.to_vector());
185181

186182
let body_indentation = indentation.nested();
187183
range

0 commit comments

Comments
 (0)