November 2018
Intermediate to advanced
390 pages
10h 8m
English
Values are immutable by default in Rust and must be tagged to be mutable:
Let a = 10;a = 11; //Error//Lets see how mutability can help hereLet mut a =10;a = 11; // It will work fine!
Mutability is also a part of the type of a borrowed pointer. Variables are immutable only by default; we can make them mutable by adding mut in front of the variable name:
fn inc(i: &mut int) { *i +=1; //It will work fine! }
Read now
Unlock full access