Merge pull request #198 from terrynsun/filenames

Use inline code formatting for filenames.
This commit is contained in:
Carol (Nichols || Goulding)
2016-08-18 08:49:41 -04:00
committed by GitHub
4 changed files with 14 additions and 14 deletions
+11 -11
View File
@@ -29,12 +29,12 @@ $ cd hello_world
### Writing and Running a Rust Program ### Writing and Running a Rust Program
Next, make a new source file and call it *main.rs*. Rust files always end with Next, make a new source file and call it `main.rs`. Rust files always end with
the *.rs* extension. If you’re using more than one word in your filename, use the `.rs` extension. If you’re using more than one word in your filename, use
an underscore to separate them. For example, you'd use *hello_world.rs* rather an underscore to separate them. For example, you'd use `hello_world.rs` rather
than *helloworld.rs*. than `helloworld.rs`.
Now open the *main.rs* file you just created, and type the following code: Now open the `main.rs` file you just created, and type the following code:
```rust ```rust
fn main() { fn main() {
@@ -142,7 +142,7 @@ do from here is run the `main` or `main.exe` file, like this:
$ ./main # or main.exe on Windows $ ./main # or main.exe on Windows
``` ```
If *main.rs* were your "Hello, world!" program, this would print `Hello, If `main.rs` were your "Hello, world!" program, this would print `Hello,
world!` to your terminal. world!` to your terminal.
If you come from a dynamic language like Ruby, Python, or JavaScript, you may If you come from a dynamic language like Ruby, Python, or JavaScript, you may
@@ -212,8 +212,8 @@ name we've chosen for our project, and Cargo creates its files in a directory
of the same name that we can then go into. of the same name that we can then go into.
If we list the files in the `hello_cargo` directory, we can see that Cargo has If we list the files in the `hello_cargo` directory, we can see that Cargo has
generated two files and one directory for us: a `Cargo.toml` and a *src* generated two files and one directory for us: a `Cargo.toml` and a `src`
directory with a *main.rs* file inside. It has also initialized a new `git` directory with a `main.rs` file inside. It has also initialized a new `git`
repository in the `hello_cargo` directory for us; you can change this to use a repository in the `hello_cargo` directory for us; you can change this to use a
different version control system, or no version control system, by using the different version control system, or no version control system, by using the
`--vcs` flag. `--vcs` flag.
@@ -266,7 +266,7 @@ and the project generated by Cargo that we've seen so far are:
1. Our code goes in the `src` directory 1. Our code goes in the `src` directory
2. The top level contains a `Cargo.toml` configuration file 2. The top level contains a `Cargo.toml` configuration file
Cargo expects your source files to live inside the *src* directory so that the Cargo expects your source files to live inside the `src` directory so that the
top-level project directory is just for READMEs, license information, top-level project directory is just for READMEs, license information,
configuration files, and anything else not related to your code. In this way, configuration files, and anything else not related to your code. In this way,
using Cargo helps you keep your projects nice and tidy. There's a place for using Cargo helps you keep your projects nice and tidy. There's a place for
@@ -297,7 +297,7 @@ Hello, world!
Bam! If all goes well, `Hello, world!` should print to the terminal once more. Bam! If all goes well, `Hello, world!` should print to the terminal once more.
Running `cargo build` for the first time also causes Cargo to create a new file Running `cargo build` for the first time also causes Cargo to create a new file
at the top level called *Cargo.lock*, which looks like this: at the top level called `Cargo.lock`, which looks like this:
```toml ```toml
[root] [root]
@@ -305,7 +305,7 @@ name = "hello_cargo"
version = "0.1.0" version = "0.1.0"
``` ```
Cargo uses the *Cargo.lock* file to keep track of dependencies in your Cargo uses the `Cargo.lock` file to keep track of dependencies in your
application. This project doesn't have dependencies, so the file is a bit application. This project doesn't have dependencies, so the file is a bit
sparse. Realistically, you won't ever need to touch this file yourself; just sparse. Realistically, you won't ever need to touch this file yourself; just
let Cargo handle it. let Cargo handle it.
@@ -17,7 +17,7 @@ $ cargo new --bin bindings
$ cd bindings $ cd bindings
``` ```
Then open *src/main.rs* and replace its code with the following: Then open `src/main.rs` and replace its code with the following:
```rust,ignore ```rust,ignore
fn main() { fn main() {
+1 -1
View File
@@ -43,7 +43,7 @@ $ cargo new --bin functions
$ cd functions $ cd functions
``` ```
Place the `another_function()` example in a file named *src/main.rs* and run Place the `another_function()` example in a file named `src/main.rs` and run
it. You should see the following output: it. You should see the following output:
```bash ```bash
+1 -1
View File
@@ -248,7 +248,7 @@ in.
The `loop` keyword tells Rust to execute a block of code over and over again The `loop` keyword tells Rust to execute a block of code over and over again
forever or until we explicitly tell it to stop. forever or until we explicitly tell it to stop.
For an example, change the *src/main.rs* file in your *loops* directory to look For an example, change the `src/main.rs` file in your *loops* directory to look
like this: like this:
```rust,ignore ```rust,ignore