Say I have the following snippet (playground)
struct A {
pub val: u32
}
const GLOBAL_A: A = A {val: 2};
fn main() {
let some_a: A = GLOBAL_A;
let other_a: A = GLOBAL_A;
println!("double val = {}", some_a.val + other_a.val);
}
Since A
is neither Clone
nor Copy
, I would assume the value of GLOBAL_A
would be moved. That does not make much sense for a const and as shown cannot be the case anyways since it can be "moved" twice.
What are the rules that allow the above snippet to work considering A
is not Clone
nor Copy
?