Init commit

This commit is contained in:
2019-02-05 07:08:31 -07:00
commit ad9ebb8920
22 changed files with 329 additions and 0 deletions

2
variables/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
**/*.rs.bk

4
variables/Cargo.lock generated Normal file
View File

@ -0,0 +1,4 @@
[[package]]
name = "variable"
version = "0.1.0"

7
variables/Cargo.toml Normal file
View 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
View 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;
}