Skip to content

Commit 6f8a7d4

Browse files
morealyouknowone
andauthored
Make loop simple with Iterator::iter
Co-authored-by: Jeong YunWon <69878+youknowone@users.noreply.github.com>
1 parent 714ce4d commit 6f8a7d4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

vm/src/stdlib/builtins.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,10 @@ mod builtins {
256256
let code = match source {
257257
Either::A(either) => {
258258
let source: &[u8] = &either.borrow_bytes();
259-
for x in source {
260-
if *x == 0 {
261-
return Err(vm.new_value_error(
262-
"source code string cannot contain null bytes".to_owned(),
263-
));
264-
}
259+
if source.iter().any(|&b| b == 0) {
260+
return Err(vm.new_value_error(
261+
"source code string cannot contain null bytes".to_owned(),
262+
));
265263
}
266264

267265
match std::str::from_utf8(source) {

0 commit comments

Comments
 (0)