33 lines
971 B
Markdown
33 lines
971 B
Markdown
# 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.
|
|
|
|
# Cargo!
|
|
|
|
Cargo is Rust's dependency manager and project creator. Using "cargo new xxx" will create a new project in a folder xxx.
|