@@ -9,7 +9,7 @@ thing to do.
99
1010The first thing that we need to do is make a file to put our code in. I like to
1111make a ` projects ` directory in my home directory, and keep all my projects
12- there. Rust does not care where our code lives.
12+ there. Rust doesn't care where our code lives.
1313
1414This actually leads to one other concern we should address: this guide will
1515assume that we have basic familiarity with the command line. Rust itself makes
@@ -71,10 +71,10 @@ were arguments, they would go inside the parentheses (`(` and `)`), and because
7171we aren’t returning anything from this function, we can omit the return type
7272entirely. We’ll get to it later.
7373
74- We ’ll also note that the function is wrapped in curly braces (` { ` and ` } ` ). Rust
75- requires these around all function bodies. It is also considered good style to
76- put the opening curly brace on the same line as the function declaration, with
77- one space in between.
74+ You ’ll also note that the function is wrapped in curly braces (` { ` and ` } ` ).
75+ Rust requires these around all function bodies. It is also considered good style
76+ to put the opening curly brace on the same line as the function declaration,
77+ with one space in between.
7878
7979Next up is this line:
8080
@@ -84,29 +84,29 @@ Next up is this line:
8484
8585This line does all of the work in our little program. There are a number of
8686details that are important here. The first is that it’s indented with four
87- spaces, not tabs. Please configure our editor of choice to insert four spaces
88- with the tab key. We provide some [ sample configurations for various
89- editors] [ configs ] .
87+ spaces, not tabs. Please configure your editor of choice to insert four spaces
88+ with the tab key. We provide some
89+ [ sample configurations for various editors] [ configs ] .
9090
9191[ configs ] : https://github.com/rust-lang/rust/tree/master/src/etc/CONFIGS.md
9292
9393The second point is the ` println!() ` part. This is calling a Rust
9494[ macro] [ macro ] , which is how metaprogramming is done in Rust. If it were a
9595function instead, it would look like this: ` println() ` . For our purposes, we
96- don’t need to worry about this difference. Just know that sometimes, we’ll see a ` ! ` ,
97- and that means that we’re calling a macro instead of a normal function. Rust
98- implements ` println! ` as a macro rather than a function for good reasons, but
99- that's an advanced topic. One last thing to mention: Rust’s macros are
100- significantly different from C macros, if we ’ve used those. Don’t be scared of
101- using macros. We’ll get to the details eventually, we ’ll just have to take it on
102- trust for now.
96+ don’t need to worry about this difference. Just know that sometimes, we’ll see a
97+ ` ! ` , and that means that we’re calling a macro instead of a normal function.
98+ Rust implements ` println! ` as a macro rather than a function for good reasons,
99+ but that's an advanced topic. One last thing to mention: Rust’s macros are
100+ significantly different from C macros, if you ’ve used those. Don’t be scared of
101+ using macros. We’ll get to the details eventually, you ’ll just have to take it
102+ on trust for now.
103103
104104[ macro ] : macros.html
105105
106106Next, ` "Hello, world!" ` is a ‘string’. Strings are a surprisingly complicated
107107topic in a systems programming language, and this is a ‘statically allocated’
108- string. If we want to read further about allocation, check out [ the stack and
109- the heap] [ allocation ] , but we don’t need to right now if we don’t want to. We
108+ string. If you want to read further about allocation, check out [ the stack and
109+ the heap] [ allocation ] , but you don’t need to right now if you don’t want to. We
110110pass this string as an argument to ` println! ` , which prints the string to the
111111screen. Easy enough!
112112
@@ -127,8 +127,8 @@ compiler, `rustc`, by passing it the name of our source file:
127127$ rustc main.rs
128128```
129129
130- This is similar to ` gcc ` or ` clang ` , if we come from a C or C++ background. Rust
131- will output a binary executable. We can see it with ` ls ` :
130+ This is similar to ` gcc ` or ` clang ` , if you come from a C or C++ background.
131+ Rust will output a binary executable. We can see it with ` ls ` :
132132
133133``` bash
134134$ ls
@@ -151,18 +151,19 @@ $ ./main # or main.exe on Windows
151151
152152This prints out our ` Hello, world! ` text to our terminal.
153153
154- If we come from a dynamic language like Ruby, Python, or JavaScript, we may not
155- be used to these two steps being separate. Rust is an ‘ahead-of-time compiled
156- language’, which means that we can compile a program, give it to someone else,
157- and they don't need to have Rust installed. If we give someone a ` .rb ` or ` .py `
158- or ` .js ` file, they need to have a Ruby/Python/JavaScript implementation
159- installed, but we just need one command to both compile and run our program.
160- Everything is a tradeoff in language design, and Rust has made its choice.
154+ If you come from a dynamic language like Ruby, Python, or JavaScript, you may
155+ not be used to these two steps being separate. Rust is an ‘ahead-of-time
156+ compiled language’, which means that we can compile a program, give it to
157+ someone else, and they don't need to have Rust installed. If we give someone a
158+ ` .rb ` or ` .py ` or ` .js ` file, they need to have a Ruby/Python/JavaScript
159+ implementation installed, but we just need one command to both compile and run
160+ our program. Everything is a tradeoff in language design, and Rust has made its
161+ choice.
161162
162- Congratulations! We have officially written a Rust program. That makes us Rust
163- programmers ! Welcome. 🎊🎉👍
163+ Congratulations! You have officially written a Rust program. That makes you a
164+ Rust programmer ! Welcome. 🎊🎉👍
164165
165- Next, I'd like to introduce us to another tool, Cargo, which is used to write
166+ Next, I'd like to introduce you to another tool, Cargo, which is used to write
166167real-world Rust programs. Just using ` rustc ` is nice for simple things, but as
167168our project grows, we'll want something to help us manage all of the options
168169that it has, and to make it easy to share our code with other people and
0 commit comments