Init commit
This commit is contained in:
2
variables/.gitignore
vendored
Normal file
2
variables/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/target
|
||||
**/*.rs.bk
|
4
variables/Cargo.lock
generated
Normal file
4
variables/Cargo.lock
generated
Normal file
@ -0,0 +1,4 @@
|
||||
[[package]]
|
||||
name = "variable"
|
||||
version = "0.1.0"
|
||||
|
7
variables/Cargo.toml
Normal file
7
variables/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "variable"
|
||||
version = "0.1.0"
|
||||
authors = ["mollusk <silvernode@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
52
variables/src/main.rs
Normal file
52
variables/src/main.rs
Normal file
@ -0,0 +1,52 @@
|
||||
fn main() {
|
||||
|
||||
//manipulate immutable variables
|
||||
let x = 5;
|
||||
|
||||
let x = x + 1;
|
||||
|
||||
let x = x * 2;
|
||||
|
||||
println!("The value of x is: {}", x);
|
||||
|
||||
|
||||
// addition
|
||||
let sum = 5 + 10;
|
||||
|
||||
// subtraction
|
||||
let difference = 95.5 - 4.3;
|
||||
|
||||
// multiplication
|
||||
let product = 4 * 30;
|
||||
|
||||
// division
|
||||
let quotient = 56.7 / 32.2;
|
||||
|
||||
// remainder
|
||||
let remainder = 43 % 5;
|
||||
|
||||
//bools
|
||||
let t = true;
|
||||
let f: bool = false; // with explicit type annotation
|
||||
|
||||
//characters
|
||||
let c = 'z';
|
||||
let z = 'ℤ';
|
||||
let heart_eyed_cat = '😻';
|
||||
|
||||
//tuples
|
||||
let tup = (500, 6.4, 1);
|
||||
|
||||
let (x, y, z) = tup;
|
||||
|
||||
println!("The value of y is: {}", y);
|
||||
|
||||
let x: (i32, f64, u8) = (500, 6.4, 1);
|
||||
|
||||
let five_hundred = x.0;
|
||||
|
||||
let six_point_four = x.1;
|
||||
|
||||
let one = x.2;
|
||||
|
||||
}
|
Reference in New Issue
Block a user