diff --git a/3-99 Research/Rust/Chapter 1 - Introduction.md b/3-99 Research/Rust/Chapter 1 - Introduction.md index e69de29b..ca54aa4f 100644 --- a/3-99 Research/Rust/Chapter 1 - Introduction.md +++ b/3-99 Research/Rust/Chapter 1 - Introduction.md @@ -0,0 +1,28 @@ +# First things first +Chapter 1 takes you through an introduction to rustc -- an older version of compiling and running rust that predates Cargo. The first thing I did was create a 'Hello, world!' program. + +I also learned that when naming files, the convention is underscores: + +**Good**: +hello_world.rs + +**Bad**: +helloworld.rs + +# What does a Rust program look like? + +Here was our full hello world program: + +```rust +fn main() { + println!("Hello, world!"); +} +``` + +First, there's the fn main() function. This is always the first piece of code that will run in a Rust program. + +Second, indents always happen with 4 spaces, not a tab. + +Third, the print statement is doing something a little different. It is a *macro*, not a function. Macros use ! at the end, while functions do not. + +Fourth, each line ends with a semicolon. Much like C. diff --git a/3-99 Research/Rust/hello_world/hello_cargo/Cargo.toml b/3-99 Research/Rust/hello_world/hello_cargo/Cargo.toml new file mode 100644 index 00000000..0f4a3432 --- /dev/null +++ b/3-99 Research/Rust/hello_world/hello_cargo/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "hello_cargo" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/3-99 Research/Rust/hello_world/hello_cargo/src/main.rs b/3-99 Research/Rust/hello_world/hello_cargo/src/main.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/3-99 Research/Rust/hello_world/hello_cargo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}