With regards to const, the rust docs state (emphasis mine):
Constants live for the entire lifetime of a program. More specifically, constants in Rust have no fixed address in memory. This is because they’re effectively inlined to each place that they’re used. References to the same constant are not necessarily guaranteed to refer to the same memory address for this reason.
So, I'm wondering how a const array is "effectively inlined." See my comments in the following snippet:
const ARR: [i32; 4] = [10, 20, 30, 40];
fn main() {
// is this
println!("{}", ARR[1]);
// the same as this?
println!("{}", [10, 20, 30, 40][1]);
// or this?
println!("{}", 20);
}
I appreciate any clarification!