Closed
Description
In below listing the assignment line I think should not compile with error like "invalid left-hand side expression" - as it would be in case variable was not a struct.
PS: Moving const definition to the function body does not change anything.
pub struct Foo {
bar: bool,
}
const CONF: Foo = Foo { bar: false };
fn main() {
println!("main 0 {}", CONF.bar); // prints false - OK
// This does compile ?!?
CONF.bar = true;
println!("main 1 {}", CONF.bar); // prints false - ?!?
}
Output:
main 0 false
main 1 false
Errors:
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 0.39s
Running `target/debug/playground`
Metadata
Metadata
Assignees
Labels
No labels