rearranged things
This commit is contained in:
parent
c073ab0d91
commit
cfe2547809
|
@ -0,0 +1,5 @@
|
||||||
|
- Variables are immutable by default
|
||||||
|
- Normal variables can have their value reassigned, mutable variables must keep the same type
|
||||||
|
and immutable variables can have their values reassigned using let again, also allowing you
|
||||||
|
to change the type (shadowing)
|
||||||
|
- Constant variables cannot have new variables reassigned to the name they use
|
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
* x is defined as an mutable variable, the value is reassigned again later without redfining it.
|
||||||
|
* mutable variables are assigned one type, and the variable cannot be any other type other than the
|
||||||
|
* one it was originally assigned.
|
||||||
|
*/
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x = 5;
|
||||||
|
println!("The value of x is: {}", x);
|
||||||
|
let x = 6;
|
||||||
|
println!("The value of x is: {}", x);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
/*
|
||||||
|
* x is defined as an immutable variable, then defined again later (shadowed?)
|
||||||
|
* redefining a variable like this lets you change the type.
|
||||||
|
*/
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x = 5;
|
||||||
|
println!("The value of x is: {}", x);
|
||||||
|
let x = 6;
|
||||||
|
println!("The value of x is: {}", x);
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
# will have compiled files and executables
|
|
||||||
debug/
|
|
||||||
target/
|
|
||||||
|
|
||||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
|
||||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
|
||||||
Cargo.lock
|
|
||||||
|
|
||||||
# These are backup files generated by rustfmt
|
|
||||||
**/*.rs.bk
|
|
|
@ -1,9 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "variables"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Emily J. <me@emily.im>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
|
@ -1,3 +0,0 @@
|
||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
Loading…
Reference in New Issue