diff --git a/src/CustomTypes/Enums.rs b/src/CustomTypes/Enums.rs index 4effcb8..3cd36f3 100644 --- a/src/CustomTypes/Enums.rs +++ b/src/CustomTypes/Enums.rs @@ -48,7 +48,7 @@ impl VeryVerboseEnumOfThingsToDoWithNumbers{ } } -fn main(){ +pub fn main(){ let pressed = WebEvent::KeyPress('x'); //`to_owned()` creates an owned `String` from a string slice. let pasted = WebEvent::Paste("my text".to_owned()); diff --git a/src/CustomTypes/Enums/CLike.rs b/src/CustomTypes/Enums/CLike.rs index a0e4977..3617598 100644 --- a/src/CustomTypes/Enums/CLike.rs +++ b/src/CustomTypes/Enums/CLike.rs @@ -15,7 +15,7 @@ enum Color{ Blue = 0x0000ff, } -fn main(){ +pub fn main(){ //`enums` can be cast as integers. println!("zero is {}", Number::Zero as i32); println!("one is {}", Number::One as i32); diff --git a/src/CustomTypes/Enums/TestCaseLinkedList.rs b/src/CustomTypes/Enums/TestCaseLinkedList.rs index c1b3f09..cc4b42b 100644 --- a/src/CustomTypes/Enums/TestCaseLinkedList.rs +++ b/src/CustomTypes/Enums/TestCaseLinkedList.rs @@ -47,7 +47,7 @@ impl List{ } } -fn main(){ +pub fn main(){ //Create an empty linked list let mut list = List::new(); diff --git a/src/CustomTypes/Enums/Use.rs b/src/CustomTypes/Enums/Use.rs index 9706439..aed5195 100644 --- a/src/CustomTypes/Enums/Use.rs +++ b/src/CustomTypes/Enums/Use.rs @@ -11,7 +11,7 @@ enum Work{ Soldier, } -fn main(){ +pub fn main(){ // Explicitly `use` each name so they are available without manual scoping. //use crate::Status::{Poor, Rich}; use Status::{Poor, Rich}; diff --git a/src/CustomTypes/Structures.rs b/src/CustomTypes/Structures.rs index 866241d..318622e 100644 --- a/src/CustomTypes/Structures.rs +++ b/src/CustomTypes/Structures.rs @@ -41,7 +41,7 @@ fn square(pnt: Point, side: f32) -> Rectangle{ return rect; } -fn main(){ +pub fn main(){ //Create struct with field init shorthand let name = "Peter"; let age = 27; diff --git a/src/HelloWorld/Comments.rs b/src/HelloWorld/Comments.rs index ef9e04a..bea7e94 100644 --- a/src/HelloWorld/Comments.rs +++ b/src/HelloWorld/Comments.rs @@ -5,7 +5,7 @@ //This is a hello world program for rust -fn main(){ +pub fn main(){ //Basic printing println!("Hello World"); let x = 5; diff --git a/src/HelloWorld/FormattedPrint.rs b/src/HelloWorld/FormattedPrint.rs index ce9a213..cdd9f8f 100644 --- a/src/HelloWorld/FormattedPrint.rs +++ b/src/HelloWorld/FormattedPrint.rs @@ -11,7 +11,7 @@ pub mod TestcaseList; pub mod Formatting; -fn main(){ +pub fn main(){ // In general, the `{}` will be automatically replaced with any // arguments. These will be stringified. println!("{} days", 31); diff --git a/src/HelloWorld/FormattedPrint/Debugging.rs b/src/HelloWorld/FormattedPrint/Debugging.rs index 59a2c67..7963029 100644 --- a/src/HelloWorld/FormattedPrint/Debugging.rs +++ b/src/HelloWorld/FormattedPrint/Debugging.rs @@ -14,7 +14,7 @@ struct Person<'a>{ age: u8 } -fn main(){ +pub fn main(){ //Printing with `{:?}` is similar to with `{}`. println!("{:?} months in a year.", 12); println!("{1:?} {0:?} is the {actor:?} name.", diff --git a/src/HelloWorld/FormattedPrint/Display.rs b/src/HelloWorld/FormattedPrint/Display.rs index 69b7fc0..3c3ae01 100644 --- a/src/HelloWorld/FormattedPrint/Display.rs +++ b/src/HelloWorld/FormattedPrint/Display.rs @@ -39,7 +39,7 @@ impl fmt::Display for Complex{ } } -fn main(){ +pub fn main(){ let minmax = MinMax(0, 14); println!("Compare structures:"); diff --git a/src/HelloWorld/FormattedPrint/Formatting.rs b/src/HelloWorld/FormattedPrint/Formatting.rs index df9f676..6e4ede3 100644 --- a/src/HelloWorld/FormattedPrint/Formatting.rs +++ b/src/HelloWorld/FormattedPrint/Formatting.rs @@ -31,7 +31,7 @@ impl Display for Color{ } } -fn main(){ +pub fn main(){ for city in[ City{ name: "Dublin", lat: 53.347778, lon: -6.259722 }, City{ name: "Oslo", lat: 59.95, lon: 10.75 }, diff --git a/src/HelloWorld/FormattedPrint/TestcaseList.rs b/src/HelloWorld/FormattedPrint/TestcaseList.rs index e128799..7a302d3 100644 --- a/src/HelloWorld/FormattedPrint/TestcaseList.rs +++ b/src/HelloWorld/FormattedPrint/TestcaseList.rs @@ -27,7 +27,7 @@ impl fmt::Display for List{ } } -fn main(){ +pub fn main(){ let v = List(vec![1, 2, 3]); println!("{}", v); } diff --git a/src/Primitives/ArraysAndSlices.rs b/src/Primitives/ArraysAndSlices.rs index a329e2a..6c685d3 100644 --- a/src/Primitives/ArraysAndSlices.rs +++ b/src/Primitives/ArraysAndSlices.rs @@ -6,7 +6,7 @@ fn analyze_slice(slice: &[i32]){ println!("the slice has {} elements", slice.len()); } -fn main(){ +pub fn main(){ //Fixed-size array (type signature is superfluous) let xs: [i32; 5] = [1, 2, 3, 4, 5]; diff --git a/src/Primitives/LiteralsAndOperators.rs b/src/Primitives/LiteralsAndOperators.rs index e4905ab..54d07b6 100644 --- a/src/Primitives/LiteralsAndOperators.rs +++ b/src/Primitives/LiteralsAndOperators.rs @@ -3,7 +3,7 @@ Integers 1, floats 1.2, characters 'a', strings "abc", booleans true and the uni Integers can, alternatively, be expressed using hexadecimal, octal or binary notation using these prefixes respectively: 0x, 0o or 0b. */ -fn main(){ +pub fn main(){ //Integer addition println!("1 + 2 = {}", 1u32 + 2); diff --git a/src/Primitives/Tuples.rs b/src/Primitives/Tuples.rs index 11bfa2b..63fa767 100644 --- a/src/Primitives/Tuples.rs +++ b/src/Primitives/Tuples.rs @@ -23,7 +23,7 @@ fn transpose(matrix: Matrix) -> Matrix{ return newMatrix; } -fn main(){ +pub fn main(){ //A tuple with a bunch of different types let long_tuple = (1u8, 2u16, 3u32, 4u64, -1i8, -2i16, -3i32, -4i64, diff --git a/src/main.rs b/src/main.rs index 12396b4..c4ade36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,5 +7,39 @@ mod CustomTypes; fn main(){ - println!("Hello World"); + //1 Hello World + //1.1 Comments + //HelloWorld::Comments::main(); + //1.2 Formatted print + //HelloWorld::FormattedPrint::main(); + //1.2.1 + //HelloWorld::FormattedPrint::Debugging::main(); + //1.2.2 + //HelloWorld::FormattedPrint::Display::main(); + //1.2.2.1 + //HelloWorld::FormattedPrint::TestcaseList::main(); + //1.2.3 + //HelloWorld::FormattedPrint::Formatting::main(); + + //2 Primitives + //2.1 LiteralsAndOperators + //Primitives::LiteralsAndOperators::main(); + //2.2 Tuples + //Primitives::Tuples::main(); + //2.3 ArraysAndSlices + //Primitives::ArraysAndSlices::main(); + + //3 Custom Types + //3.1 Structures + //CustomTypes::Structures::main(); + //3.2 Enums + //CustomTypes::Enums::main(); + //3.2.1 Use + //CustomTypes::Enums::Use::main(); + //3.2.2 C-Like + //CustomTypes::Enums::CLike::main(); + //3.2.3 Testcase - Linked-list + //CustomTypes::Enums::TestCaseLinkedList::main(); + //3.3 Constants + //CustomTypes::Constants::main(); }