summaryrefslogtreecommitdiffstats
path: root/src/test/codegen/zip.rs
blob: e55f4f1a2de3a4c7b3856e59b7d90406fe59ba39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 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
    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;
    }
}