rust/tests/codegen/zip.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
432 B
Rust
Raw Normal View History

2016-04-21 19:35:39 +00:00
//@ compile-flags: -C no-prepopulate-passes -O
#![crate_type = "lib"]
// CHECK-LABEL: @zip_copy
#[no_mangle]
pub fn zip_copy(xs: &[u8], ys: &mut [u8]) {
// CHECK: memcpy
2016-04-21 19:35:39 +00:00
for (x, y) in xs.iter().zip(ys) {
*y = *x;
}
}
// CHECK-LABEL: @zip_copy_mapped
#[no_mangle]
pub fn zip_copy_mapped(xs: &[u8], ys: &mut [u8]) {
// CHECK: memcpy
for (x, y) in xs.iter().map(|&x| x).zip(ys) {
*y = x;
}
}