Skip to content

Commit

Permalink
Simplify the consumption of the iterator
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Cattermole <[email protected]>
Signed-off-by: Alex Snaps <[email protected]>
  • Loading branch information
alexsnaps and adam-cattermole committed Nov 5, 2024
1 parent 7f9fb6a commit ce0e4f8
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/data/cel/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,10 @@ pub fn substring(This(this): This<Arc<String>>, Arguments(args): Arguments) -> R
message: format!("Can't have end be before the start: `{end} < {start}"),
})?
}
end -= start;
Ok(this
.chars()
.skip(start)
.take_while(|_| {
if let Some(v) = end.checked_sub(1) {
end = v;
true
} else {
false
}
})
.take(end - start)
.collect::<String>()
.into())
}
Expand Down

0 comments on commit ce0e4f8

Please sign in to comment.