diff --git a/.gitignore b/.gitignore index 73f1102..12b9df0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ .vscode/ #Ignore all executables -*.exe - +target/ +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..13c65b0 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "Tutorials" +version = "0.1.0" +authors = ["Mattrixwv "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/CustomTypes.rs b/src/CustomTypes.rs new file mode 100644 index 0000000..c2480e9 --- /dev/null +++ b/src/CustomTypes.rs @@ -0,0 +1,3 @@ +pub mod Structures; +pub mod Enums; +pub mod Constants; \ No newline at end of file diff --git a/3.CustomTypes/3Constants.rs b/src/CustomTypes/Constants.rs similarity index 96% rename from 3.CustomTypes/3Constants.rs rename to src/CustomTypes/Constants.rs index 3bc183b..79bd043 100644 --- a/3.CustomTypes/3Constants.rs +++ b/src/CustomTypes/Constants.rs @@ -7,7 +7,7 @@ fn is_big(n: i32) -> bool{ n > THRESHOLD } -fn main(){ +pub fn main(){ let n = 16; //Access constant in the main thread diff --git a/3.CustomTypes/2Enums.rs b/src/CustomTypes/Enums.rs similarity index 95% rename from 3.CustomTypes/2Enums.rs rename to src/CustomTypes/Enums.rs index 3a60fcb..4effcb8 100644 --- a/3.CustomTypes/2Enums.rs +++ b/src/CustomTypes/Enums.rs @@ -1,3 +1,8 @@ +pub mod Use; +pub mod CLike; +pub mod TestCaseLinkedList; + + //Create an `enum` to classify a web event. Note how both //names and type information together specify the variant: //`PageLoad != PageUnload` and `KeyPress(char) != Paste(String)`. @@ -58,5 +63,5 @@ fn main(){ inspect(unload); // We can refer to each variant via its alias, not its long and inconvenient name. - let x = Operations::Add; + //let x = Operations::Add; } diff --git a/3.CustomTypes/2.Enums/2CLike.rs b/src/CustomTypes/Enums/CLike.rs similarity index 100% rename from 3.CustomTypes/2.Enums/2CLike.rs rename to src/CustomTypes/Enums/CLike.rs diff --git a/3.CustomTypes/2.Enums/3TestCase-LinkedList.rs b/src/CustomTypes/Enums/TestCaseLinkedList.rs similarity index 98% rename from 3.CustomTypes/2.Enums/3TestCase-LinkedList.rs rename to src/CustomTypes/Enums/TestCaseLinkedList.rs index a9cb710..c1b3f09 100644 --- a/3.CustomTypes/2.Enums/3TestCase-LinkedList.rs +++ b/src/CustomTypes/Enums/TestCaseLinkedList.rs @@ -1,4 +1,4 @@ -use crate::List::*; +use List::*; enum List{ //Cons: Tuple struct that wraps an element and a pointer to the next node diff --git a/3.CustomTypes/2.Enums/1Use.rs b/src/CustomTypes/Enums/Use.rs similarity index 87% rename from 3.CustomTypes/2.Enums/1Use.rs rename to src/CustomTypes/Enums/Use.rs index 7e41c5b..9706439 100644 --- a/3.CustomTypes/2.Enums/1Use.rs +++ b/src/CustomTypes/Enums/Use.rs @@ -13,9 +13,11 @@ enum Work{ fn main(){ // Explicitly `use` each name so they are available without manual scoping. - use crate::Status::{Poor, Rich}; + //use crate::Status::{Poor, Rich}; + use Status::{Poor, Rich}; //Automatically `use` each name inside `Work`. - use crate::Work::*; + //use crate::Work::*; + use Work::*; //Equivalent to `Status::Poor`. let status = Poor; diff --git a/3.CustomTypes/1Structures.rs b/src/CustomTypes/Structures.rs similarity index 100% rename from 3.CustomTypes/1Structures.rs rename to src/CustomTypes/Structures.rs diff --git a/src/HelloWorld.rs b/src/HelloWorld.rs new file mode 100644 index 0000000..c200650 --- /dev/null +++ b/src/HelloWorld.rs @@ -0,0 +1,2 @@ +pub mod Comments; +pub mod FormattedPrint; \ No newline at end of file diff --git a/1.HelloWorld/1Comments.rs b/src/HelloWorld/Comments.rs similarity index 100% rename from 1.HelloWorld/1Comments.rs rename to src/HelloWorld/Comments.rs diff --git a/1.HelloWorld/2FormattedPrint.rs b/src/HelloWorld/FormattedPrint.rs similarity index 95% rename from 1.HelloWorld/2FormattedPrint.rs rename to src/HelloWorld/FormattedPrint.rs index 6bd5307..ce9a213 100644 --- a/1.HelloWorld/2FormattedPrint.rs +++ b/src/HelloWorld/FormattedPrint.rs @@ -5,6 +5,12 @@ //This is a hello world program for rust +pub mod Debugging; +pub mod Display; +pub mod TestcaseList; +pub mod Formatting; + + fn main(){ // In general, the `{}` will be automatically replaced with any // arguments. These will be stringified. diff --git a/1.HelloWorld/2.FormattedPrint/1Debugging.rs b/src/HelloWorld/FormattedPrint/Debugging.rs similarity index 100% rename from 1.HelloWorld/2.FormattedPrint/1Debugging.rs rename to src/HelloWorld/FormattedPrint/Debugging.rs diff --git a/1.HelloWorld/2.FormattedPrint/2Display.rs b/src/HelloWorld/FormattedPrint/Display.rs similarity index 100% rename from 1.HelloWorld/2.FormattedPrint/2Display.rs rename to src/HelloWorld/FormattedPrint/Display.rs diff --git a/1.HelloWorld/2.FormattedPrint/3Formatting.rs b/src/HelloWorld/FormattedPrint/Formatting.rs similarity index 100% rename from 1.HelloWorld/2.FormattedPrint/3Formatting.rs rename to src/HelloWorld/FormattedPrint/Formatting.rs diff --git a/1.HelloWorld/2.FormattedPrint/2-1-Testcase-List.rs b/src/HelloWorld/FormattedPrint/TestcaseList.rs similarity index 100% rename from 1.HelloWorld/2.FormattedPrint/2-1-Testcase-List.rs rename to src/HelloWorld/FormattedPrint/TestcaseList.rs diff --git a/src/Primitives.rs b/src/Primitives.rs new file mode 100644 index 0000000..a03880d --- /dev/null +++ b/src/Primitives.rs @@ -0,0 +1,3 @@ +pub mod LiteralsAndOperators; +pub mod Tuples; +pub mod ArraysAndSlices; \ No newline at end of file diff --git a/2.Primitives/3ArraysAndSlices.rs b/src/Primitives/ArraysAndSlices.rs similarity index 100% rename from 2.Primitives/3ArraysAndSlices.rs rename to src/Primitives/ArraysAndSlices.rs diff --git a/2.Primitives/1LiteralsAndOperators.rs b/src/Primitives/LiteralsAndOperators.rs similarity index 100% rename from 2.Primitives/1LiteralsAndOperators.rs rename to src/Primitives/LiteralsAndOperators.rs diff --git a/2.Primitives/2Tuples.rs b/src/Primitives/Tuples.rs similarity index 100% rename from 2.Primitives/2Tuples.rs rename to src/Primitives/Tuples.rs diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..12396b4 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,11 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] + +mod HelloWorld; +mod Primitives; +mod CustomTypes; + + +fn main(){ + println!("Hello World"); +}