Skip to content

Commit 1ab812e

Browse files
committed
Revert "rust set length checks"
This reverts commit 4433435.
1 parent 4433435 commit 1ab812e

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/input/return_enums.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,30 +176,22 @@ fn validate_iter_to_set<'a, 's>(
176176
recursion_guard: &'s mut RecursionGuard,
177177
) -> ValResult<'a, ()> {
178178
let mut errors: Vec<ValLineError> = Vec::new();
179-
let mut spaces_left = max_length.unwrap_or(0);
180179
for (index, item_result) in iter.enumerate() {
181180
let item = item_result.map_err(|e| any_next_error!(py, e, input, index))?;
182181
match validator.validate(py, item, extra, definitions, recursion_guard) {
183182
Ok(item) => {
184183
set.build_add(item)?;
185184
if let Some(max_length) = max_length {
186-
match spaces_left.checked_sub(1) {
187-
Some(spaces) => spaces_left = spaces,
188-
None => {
189-
let actual_length = set.build_len();
190-
if actual_length > max_length {
191-
return Err(ValError::new(
192-
ErrorType::TooLong {
193-
field_type: field_type.to_string(),
194-
max_length,
195-
actual_length,
196-
},
197-
input,
198-
));
199-
} else {
200-
spaces_left = max_length - actual_length;
201-
}
202-
}
185+
let actual_length = set.build_len();
186+
if actual_length > max_length {
187+
return Err(ValError::new(
188+
ErrorType::TooLong {
189+
field_type: field_type.to_string(),
190+
max_length,
191+
actual_length,
192+
},
193+
input,
194+
));
203195
}
204196
}
205197
}

0 commit comments

Comments
 (0)