Skip to content

Commit 915fb2b

Browse files
committed
auto merge of rust-lang#15884 : steveklabnik/rust/guide_fix_headings, r=huonw
I screwed this up a while back, and now that I have no outstanding PRs, it's a good time to fix this.
2 parents bfcde30 + 1e9f86b commit 915fb2b

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

src/doc/guide.md

+38-38
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ displayed here in line with Rust's open development policy. Please open any
77
issues you find as usual.
88
</div>
99

10-
## Welcome!
10+
# Welcome!
1111

1212
Hey there! Welcome to the Rust guide. This is the place to be if you'd like to
1313
learn how to program in Rust. Rust is a systems programming language with a
@@ -24,7 +24,7 @@ more advanced things.
2424

2525
Sound good? Let's go!
2626

27-
## Installing Rust
27+
# Installing Rust
2828

2929
The first step to using Rust is to install it! There are a number of ways to
3030
install Rust, but the easiest is to use the the `rustup` script. If you're on
@@ -106,7 +106,7 @@ mailing list](https://mail.mozilla.org/listinfo/rust-dev), [the /r/rust
106106
subreddit](http://www.reddit.com/r/rust), and [Stack
107107
Overflow](http://stackoverflow.com/questions/tagged/rust).
108108

109-
## Hello, world!
109+
# Hello, world!
110110

111111
Now that you have Rust installed, let's write your first Rust program. It's
112112
traditional to make your first program in any new language one that prints the
@@ -266,7 +266,7 @@ your project grows, you'll want something to help you manage all of the options
266266
that it has, and to make it easy to share your code with other people and
267267
projects.
268268

269-
## Hello, Cargo!
269+
# Hello, Cargo!
270270

271271
[Cargo](http://crates.io) is a tool that Rustaceans use to help manage their
272272
Rust projects. Cargo is currently in an alpha state, just like Rust, and so it
@@ -362,7 +362,7 @@ Now that you've got the tools down, let's actually learn more about the Rust
362362
language itself. These are the basics that will serve you well through the rest
363363
of your time with Rust.
364364

365-
## Variable bindings
365+
# Variable bindings
366366

367367
The first thing we'll learn about are 'variable bindings.' They look like this:
368368

@@ -532,7 +532,7 @@ must initialize the binding before we use it? And how does it know that we have
532532
or have not initialized the binding? For that, we need to learn our next
533533
concept: `if`.
534534

535-
## If
535+
# If
536536

537537
Rust's take on `if` is not particularly complex, but it's much more like the
538538
`if` you'll find in a dynamically typed language than in a more traditional
@@ -593,7 +593,7 @@ This reveals two interesting things about Rust: it is an expression-based
593593
language, and semicolons are different than in other 'curly brace and
594594
semicolon'-based languages. These two things are related.
595595

596-
### Expressions vs. Statements
596+
## Expressions vs. Statements
597597

598598
Rust is primarily an expression based language. There are only two kinds of
599599
statements, and everything else is an expression.
@@ -681,7 +681,7 @@ unit instead.
681681
There's one more time in which you won't see a semicolon at the end of a line
682682
of Rust code. For that, we'll need our next concept: functions.
683683

684-
## Functions
684+
# Functions
685685

686686
You've already seen one function so far, the `main` function:
687687

@@ -829,7 +829,7 @@ There are some additional ways to define functions, but they involve features
829829
that we haven't learned about yet, so let's just leave it at that for now.
830830

831831

832-
## Comments
832+
# Comments
833833

834834
Now that we have some functions, it's a good idea to learn about comments.
835835
Comments are notes that you leave to other programmers to help explain things
@@ -877,13 +877,13 @@ You can use the `rustdoc` tool to generate HTML documentation from these doc
877877
comments. We will talk more about `rustdoc` when we get to modules, as
878878
generally, you want to export documentation for a full module.
879879

880-
## Compound Data Types
880+
# Compound Data Types
881881

882882
Rust, like many programming languages, has a number of different data types
883883
that are built-in. You've already done some simple work with integers and
884884
strings, but next, let's talk about some more complicated ways of storing data.
885885

886-
### Tuples
886+
## Tuples
887887

888888
The first compound data type we're going to talk about are called **tuple**s.
889889
Tuples are an ordered list of a fixed size. Like this:
@@ -958,7 +958,7 @@ can destructure a pattern returned by a function, as well.
958958
Tuples are a very simple data structure, and so are not often what you want.
959959
Let's move on to their bigger sibling, structs.
960960

961-
### Structs
961+
## Structs
962962

963963
A struct is another form of a 'record type,' just like a tuple. There's a
964964
difference: structs give each element that they contain a name, called a
@@ -1008,7 +1008,7 @@ fn main() {
10081008

10091009
This will print `The point is at (5, 0)`.
10101010

1011-
### Tuple Structs and Newtypes
1011+
## Tuple Structs and Newtypes
10121012

10131013
Rust has another data type that's like a hybrid between a tuple and a struct,
10141014
called a **tuple struct**. Tuple structs do have a name, but their fields
@@ -1064,7 +1064,7 @@ println!("length is {} inches", integer_length);
10641064
As you can see here, you can extract the inner integer type through a
10651065
destructuring `let`.
10661066

1067-
### Enums
1067+
## Enums
10681068

10691069
Finally, Rust has a "sum type", an **enum**. Enums are an incredibly useful
10701070
feature of Rust, and are used throughout the standard library. Enums look
@@ -1161,7 +1161,7 @@ useful when they're generic across types. But before we get to generics, let's
11611161
talk about how to fix this big `if`/`else` statements we've been writing. We'll
11621162
do that with `match`.
11631163

1164-
## Match
1164+
# Match
11651165

11661166
Often, a simple `if`/`else` isn't enough, because you have more than two
11671167
possible options. And `else` conditions can get incredibly complicated. So
@@ -1283,12 +1283,12 @@ fn main() {
12831283
In this case, it doesn't make a lot of sense, as we are just making a temporary
12841284
string where we don't need to, but sometimes, it's a nice pattern.
12851285

1286-
## Looping
1286+
# Looping
12871287

12881288
Looping is the last basic construct that we haven't learned yet in Rust. Rust has
12891289
two main looping constructs: `for` and `while`.
12901290

1291-
### `for`
1291+
## `for`
12921292

12931293
The `for` loop is used to loop a particular number of times. Rust's `for` loops
12941294
work a bit differently than in other systems languages, however. Rust's `for`
@@ -1337,7 +1337,7 @@ lists three things. This happens quite a bit with "C style" `for` loops.
13371337

13381338
We'll talk more about `for` when we cover **vector**s, later in the Guide.
13391339

1340-
### `while`
1340+
## `while`
13411341

13421342
The other kind of looping construct in Rust is the `while` loop. It looks like
13431343
this:
@@ -1375,7 +1375,7 @@ general, the more information we can give to the compiler, the better it
13751375
can do with safety and code generation. So you should always prefer
13761376
`loop` when you plan to loop infinitely.
13771377

1378-
### Ending iteration early
1378+
## Ending iteration early
13791379

13801380
Let's take a look at that `while` loop we had earlier:
13811381

@@ -1426,7 +1426,7 @@ building our guessing game, but we need to know how to do one last thing first:
14261426
get input from the keyboard. You can't have a guessing game without the ability
14271427
to guess!
14281428

1429-
## Standard Input
1429+
# Standard Input
14301430

14311431
Getting input from the keyboard is pretty easy, but uses some things
14321432
we haven't seen before. Here's a simple program that reads some input,
@@ -1586,7 +1586,7 @@ here.
15861586
That's all you need to get basic input from the standard input! It's not too
15871587
complicated, but there are a number of small parts.
15881588

1589-
## Guessing Game
1589+
# Guessing Game
15901590

15911591
Okay! We've got the basics of Rust down. Let's write a bigger program.
15921592

@@ -1597,7 +1597,7 @@ Upon entering our guess, it will tell us if we're too low or too high. Once we
15971597
guess correctly, it will congratulate us, and print the number of guesses we've
15981598
taken to the screen. Sound good?
15991599

1600-
### Set up
1600+
## Set up
16011601

16021602
Let's set up a new project. Go to your projects directory, and make a new
16031603
directory for the project, as well as a `src` directory for our code:
@@ -1645,7 +1645,7 @@ Excellent! Open up your `src/guessing_game.rs` again. We'll be writing all of
16451645
our code in this file. We'll talk about multiple-file projects later on in the
16461646
guide.
16471647

1648-
### Processing a Guess
1648+
## Processing a Guess
16491649

16501650
Let's get to it! The first thing we need to do for our guessing game is
16511651
allow our player to input a guess. Put this in your `src/guessing_game.rs`:
@@ -1674,7 +1674,7 @@ user to input a guess, get their input, and then print it out.
16741674
Because we talked about this in the section on standard I/O, I won't go into
16751675
more details here. If you need a refresher, go re-read that section.
16761676

1677-
### Generating a secret number
1677+
## Generating a secret number
16781678

16791679
Next, we need to generate a secret number. To do that, we need to use Rust's
16801680
random number generation, which we haven't talked about yet. Rust includes a
@@ -1845,7 +1845,7 @@ You guessed: 3
18451845

18461846
Great! Next up: let's compare our guess to the secret guess.
18471847

1848-
### Comparing guesses
1848+
## Comparing guesses
18491849

18501850
If you remember, earlier in the tutorial, we made a `cmp` function that compared
18511851
two numbers. Let's add that in, along with a `match` statement to compare the
@@ -2194,7 +2194,7 @@ the error messages help guide you towards the correct types.
21942194
Now we've got most of the game working, but we can only make one guess. Let's
21952195
change that by adding loops!
21962196

2197-
### Looping
2197+
## Looping
21982198

21992199
As we already discussed, the `loop` key word gives us an infinite loop. So
22002200
let's add that in:
@@ -2455,7 +2455,7 @@ fn cmp(a: uint, b: uint) -> Ordering {
24552455
}
24562456
```
24572457

2458-
### Complete!
2458+
## Complete!
24592459

24602460
At this point, you have successfully built the Guessing Game! Congratulations!
24612461

@@ -2467,36 +2467,36 @@ rest of your Rust education.
24672467
Now that you're an expert at the basics, it's time to learn about some of
24682468
Rust's more unique features.
24692469

2470-
## iterators
2470+
# iterators
24712471

2472-
## Lambdas
2472+
# Lambdas
24732473

2474-
## Testing
2474+
# Testing
24752475

24762476
attributes
24772477

24782478
stability markers
24792479

2480-
## Crates and Modules
2480+
# Crates and Modules
24812481

24822482
visibility
24832483

24842484

2485-
## Generics
2485+
# Generics
24862486

2487-
## Traits
2487+
# Traits
24882488

2489-
## Operators and built-in Traits
2489+
# Operators and built-in Traits
24902490

2491-
## Ownership and Lifetimes
2491+
# Ownership and Lifetimes
24922492

24932493
Move vs. Copy
24942494

24952495
Allocation
24962496

2497-
## Tasks
2497+
# Tasks
24982498

2499-
## Macros
2499+
# Macros
25002500

2501-
## Unsafe
2501+
# Unsafe
25022502

0 commit comments

Comments
 (0)