Hacker News new | ask | show | jobs
by jjtheblunt 843 days ago
> In Rust you can take any data structure and mutate it.

What if a memory location not marked "mut" is allocated by the compiler in the executable TEXT segment, so the virtual memory page is itself mapped read only?

Are you certain you can get away with what you said, within the promises of the compiler?

1 comments

The underlying object type would still be mutable in this case, you just can't get a &mut reference to the object.
You get a segmentation violation if you try writing to a read-only page as in variables in a .text segment.

Are we talking about different things? I'm writing Rust too (and decades of C) and feel I'm missing what you're describing, perhaps.