Skip to content

fix doc #24837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed

fix doc #24837

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/doc/complement-lang-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Some examples that demonstrate different aspects of the language:
* The standard library's [json] module. Enums and pattern matching

[sprocketnes]: https://github.com/pcwalton/sprocketnes
[hash]: https://github.com/rust-lang/rust/blob/master/src/libstd/hash/mod.rs
[HashMap]: https://github.com/rust-lang/rust/blob/master/src/libcollections/hashmap.rs
[hash]: https://github.com/rust-lang/rust/blob/master/src/libcore/hash/mod.rs
[HashMap]: https://github.com/rust-lang/rust/blob/master/src/libstd/collections/hash/map.rs#L309
[json]: https://github.com/rust-lang/rust/blob/master/src/libserialize/json.rs

You may also be interested in browsing [trending Rust repositories][github-rust] on GitHub.
Expand Down
22 changes: 11 additions & 11 deletions src/doc/trpl/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ or cumbersome to express that pattern as a generic function, a trait, or
anything else within Rust’s semantics.

Macros allow us to abstract at a syntactic level. A macro invocation is
shorthand for an "expanded" syntactic form. This expansion happens early in
shorthand for an expanded syntactic form. This expansion happens early in
compilation, before any static checking. As a result, macros can capture many
patterns of code reuse that Rust’s core abstractions cannot.

Expand All @@ -23,7 +23,7 @@ difficult to design a well-behaved macro! Additionally, compiler errors in
macro code are harder to interpret, because they describe problems in the
expanded code, not the source-level form that developers use.

These drawbacks make macros something of a "feature of last resort". That’s not
These drawbacks make macros something of a feature of last resort. That’s not
to say that macros are bad; they are part of Rust because sometimes they’re
needed for truly concise, well-abstracted code. Just keep this tradeoff in
mind.
Expand Down Expand Up @@ -98,7 +98,7 @@ cases. Above, we had

This is like a `match` expression arm, but the matching happens on Rust syntax
trees, at compile time. The semicolon is optional on the last (here, only)
case. The "pattern" on the left-hand side of `=>` is known as a ‘matcher’.
case. The pattern on the left-hand side of `=>` is known as a ‘matcher’.
These have [their own little grammar] within the language.

[their own little grammar]: ../reference.html#macros
Expand Down Expand Up @@ -154,7 +154,7 @@ $(
```

Each matched expression `$x` will produce a single `push` statement in the
macro expansion. The repetition in the expansion proceeds in "lockstep" with
macro expansion. The repetition in the expansion proceeds in lockstep with
repetition in the matcher (more on this in a moment).

Because `$x` was already declared as matching an expression, we don’t repeat
Expand Down Expand Up @@ -190,7 +190,7 @@ shorthand for a data type could be valid as either an expression or a pattern.

The repetition operator follows two principal rules:

1. `$(...)*` walks through one "layer" of repetitions, for all of the `$name`s
1. `$(...)*` walks through one layer of repetitions, for all of the `$name`s
it contains, in lockstep, and
2. each `$name` must be under at least as many `$(...)*`s as it was matched
against. If it is under more, it’ll be duplicated, as appropriate.
Expand Down Expand Up @@ -219,12 +219,12 @@ fn main() {
```

That’s most of the matcher syntax. These examples use `$(...)*`, which is a
"zero or more" match. Alternatively you can write `$(...)+` for a "one or
more" match. Both forms optionally include a separator, which can be any token
zero or more match. Alternatively you can write `$(...)+` for a one or
more match. Both forms optionally include a separator, which can be any token
except `+` or `*`.

This system is based on
"[Macro-by-Example](http://www.cs.indiana.edu/ftp/techreports/TR206.pdf)"
[Macro-by-Example](http://www.cs.indiana.edu/ftp/techreports/TR206.pdf)
(PDF link).

# Hygiene
Expand Down Expand Up @@ -316,7 +316,7 @@ fn main() {
This works because Rust has a [hygienic macro system][]. Each macro expansion
happens in a distinct ‘syntax context’, and each variable is tagged with the
syntax context where it was introduced. It’s as though the variable `state`
inside `main` is painted a different "color" from the variable `state` inside
inside `main` is painted a different color from the variable `state` inside
the macro, and therefore they don’t conflict.

[hygienic macro system]: http://en.wikipedia.org/wiki/Hygienic_macro
Expand Down Expand Up @@ -418,7 +418,7 @@ tell you about the syntax contexts.
they are unstable and require feature gates.

* `log_syntax!(...)` will print its arguments to standard output, at compile
time, and "expand" to nothing.
time, and expand to nothing.

* `trace_macros!(true)` will enable a compiler message every time a macro is
expanded. Use `trace_macros!(false)` later in expansion to turn it off.
Expand Down Expand Up @@ -471,7 +471,7 @@ which syntactic form it matches.
* `block`: a brace-delimited sequence of statements. Example:
`{ log(error, "hi"); return 12; }`.
* `item`: an [item][]. Examples: `fn foo() { }`; `struct Bar;`.
* `meta`: a "meta item", as found in attributes. Example: `cfg(target_os = "windows")`.
* `meta`: a meta item, as found in attributes. Example: `cfg(target_os = "windows")`.
* `tt`: a single token tree.

There are additional rules regarding the next token after a metavariable:
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/mutability.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ philosophy, memory safety, and the mechanism by which Rust guarantees it, the

> You may have one or the other of these two kinds of borrows, but not both at
> the same time:
>
>
> * one or more references (`&T`) to a resource.
> * exactly one mutable reference (`&mut T`)

Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/unsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ two contexts. The first one is to mark a function as unsafe:

```rust
unsafe fn danger_will_robinson() {
// scary stuff
// scary stuff
}
```

Expand Down
3 changes: 2 additions & 1 deletion src/doc/trpl/vectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ There’s an alternate form of `vec!` for repeating an initial value:
let v = vec![0; 10]; // ten zeroes
```

[generic]: generics.html

## Accessing elements

To get the value at a particular index in the vector, we use `[]`s:
Expand Down Expand Up @@ -57,4 +59,3 @@ Vectors have many more useful methods, which you can read about in [their
API documentation][vec].

[vec]: ../std/vec/index.html
[generic]: generics.html