Skip to content
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

More small syntax changes in reference.md #24760

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 4 additions & 4 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2640,7 +2640,7 @@ parentheses. They are used to create [tuple-typed](#tuple-types) values.
```{.tuple}
(0,);
(0.0, 4.5);
("a", 4us, true);
("a", 4usize, true);
```

### Unit expressions
Expand Down Expand Up @@ -3163,7 +3163,7 @@ An example of a for loop over the contents of an array:

let v: &[Foo] = &[a, b, c];

for e in v.iter() {
for e in v {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this technically changes behavior, though I'm not sure it matters here. &v would give you iter(), just v gives into_iter().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since v is already a reference, it appears that the for loop is actually using v.iter(). This code fails, but replacing it with v.iter() works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, i missed that v was a slice! I clicked merge regardless.

bar(*e);
}
```
Expand Down Expand Up @@ -3694,12 +3694,12 @@ Within the body of an item that has type parameter declarations, the names of
its type parameters are types:

```ignore
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
fn map<A: Clone, B: Clone, F: Fn(A) -> B>(f: F, xs: &[A]) -> Vec<B> {
if xs.is_empty() {
return vec![];
}
let first: B = f(xs[0].clone());
let mut rest: Vec<B> = map(f, xs.slice(1, xs.len()));
let mut rest: Vec<B> = map(f, &xs[1..]);
rest.insert(0, first);
return rest;
}
Expand Down