FM
>>FIRST MISSION//LOGS//diagram//simple-rust-mutation-relationship-diagram.MD
[ + ] TARGET_LOCKED200 OK
SEP 29, 2021timer 3 MIN READSYS_TAG: diagram STATUS: VERIFIED_WORKING

Simple Rust Mutation Relationship Diagram

ENGINE: KERNEL // STABLE
BASE_ARCH: x86_64
HOST: VASTORIGINS.COM
GPG: OKSIG_ID: 0x4EB27DB0
Simple Rust Mutation Relationship Diagram
SPEC_IMAGE // PROVENANCE_VERIFIED

Rust mutation can be somewhat confusing if you’re a beginner. It’s similar to C++ way of doing things on where to put the asterisk (*) and ampersand (&) sign in variable declaration. Moving the asterisk sign and ampersand sign makes the declaration sometimes more mutable and also can make it less mutable.

Here is a simple diagram on Rust mutation that I found on StackOverflow (SO). I can’t find the exact link to reference as this one is stored in my notes.


a: &T == const T* const a;      // can't mutate either
    mut a: &T == const T* a;            // can't mutate what is pointed to
    a: &mut T == T* const a;            // can't mutate pointer
mut a: &mut T == T* a;                  // can mutate both
[ SIGNATURE VERIFIED // GPG 0x4EB27DB0 // PROVENANCE SECURE ]
➔ RETURN TO LOGS