. - " , ". :
const ARR: [i32; 4] = [10, 20, 30, 40];
#[inline(never)] fn show(v: i32) { println!("{}", v); }
fn main() {
// is this
show(ARR[1]);
// the same as this?
show([10, 20, 30, 40][1]);
// or this?
show(20);
}
, LLVM IR , main:
define internal void @_ZN4main20hf87c9a461739c547ZaaE() unnamed_addr #4 {
entry-block:
call void @_ZN4show20h659b6b1f4f7103c4naaE(i32 20)
call void @_ZN4show20h659b6b1f4f7103c4naaE(i32 20)
call void @_ZN4show20h659b6b1f4f7103c4naaE(i32 20)
ret void
}
show, 20. !
, , show . , "inlined" , ; . - Rust, , .