Fisrt commit

This commit is contained in:
Eduardo Cueto Mendoza 2020-07-16 22:01:23 -06:00
commit bc133dc11e
7 changed files with 67 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

5
Cargo.lock generated Normal file
View File

@ -0,0 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "hello_world"
version = "0.1.0"

9
Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "hello_world"
version = "0.1.0"
authors = ["Eduardo Cueto Mendoza <cueto303@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

9
src/main.rs Normal file
View File

@ -0,0 +1,9 @@
//mod print;
//mod vars;
mod types;
fn main() {
//print::run();
//vars::run();
types::run();
}

27
src/print.rs Normal file
View File

@ -0,0 +1,27 @@
pub fn run() {
// print to console
println!("Hello from the print.rs file");
// Basic formatting
println!("Number: {}",1);
println!("{} is from {}", "Brad", "Mass");
// Positional Arguments
println!("{0} is from {1} and {0} likes to {2}", "Brad", "Mass", "code");
// Named arguments
println!(
"{name} likes to play {activity}",
name="John",
activity="baseball"
);
// Placeholder traits
println!("Binary: {:b} Hex: {:x} Octal: {:o}", 10,10,10);
// Placeholder for debug trait
print!("{:?}", (12,true,"hello"));
// Basic math
print!("10 + 10 = {}", 10 + 10);
}

1
src/types.rs Normal file
View File

@ -0,0 +1 @@
pub fn run() {}

15
src/vars.rs Normal file
View File

@ -0,0 +1,15 @@
pub fn run() {
let name = "Brad";
let mut age = 37;
println!("My name is {} and I am {}", name, age);
age = 38;
println!("My name is {} and I am {}", name, age);
// Define constant
const ID: i32 = 001;
println!("ID: {}", ID);
// Assign multiple vars
let ( my_name, my_age ) = ("Brad", 37);
println!("{} is {}", my_name, my_age);
}