Commit Graph

375 Commits

Author SHA1 Message Date
Tshepang Lekhonkhobe
0eafc3228b doc: remove repeated info 2014-12-24 21:06:27 +02:00
Alex Crichton
941361b395 rollup merge of #20102: tshepang/patch-4
That sentence made it look like there was no option for using 'mut'
2014-12-22 12:47:52 -08:00
Alex Crichton
082bfde412 Fallout of std::str stabilization 2014-12-21 23:31:42 -08:00
Alex Crichton
5acb622f5b rollup merge of #19957: tshepang/patch-1 2014-12-21 09:26:42 -08:00
Alex Crichton
693cfab5a6 rollup merge of #19823: iKevinY/doc-fixes
I was reading through the Rust Guide (hopefully looking to learn some Rust), and I figured it would be a good idea to open a pull request with some of the errata I noticed along the way. Most of the changes are pretty mundane, but there are a couple that might raise a bit of discussion.

### Punctuation outside of 'key term' quotes

This is something that was inconsistent in the Guide. While the convention in American English is to place punctuation immediately following a quotation mark *inside* the quotation mark, it seems strange to do this with 'key terms', considering they are not a true quotation.

### Changed comment placement in 17.2 code block

This is what the code block in [17.2 — Ownership, borrowing, and lifetimes](http://doc.rust-lang.org/guide.html#ownership,-borrowing,-and-lifetimes) looks like in fullscreened Safari 8:

![screen shot 2014-12-13 at 2 48 47 pm](https://cloud.githubusercontent.com/assets/2434728/5425704/2fff3bf0-82d7-11e4-8c8f-d594acde8937.png)

Some of the comments extend *just* too far, causing them to bleed into the next line, so I moved a few of them above the relevant lines of code to avoid this.
2014-12-21 09:26:40 -08:00
Tshepang Lekhonkhobe
7d55249c91 doc: add missing "by default"
That sentence made it look like there was no option for using 'mut'
2014-12-21 09:32:32 +02:00
Kevin Yap
1919de87bb Miscellaneous changes to Rust Guide
- Various grammatical changes
- Place punctuation outside of key term quotes
- Change comment placement in 17.2 code block
- Replace double hyphens with en dashes
2014-12-19 10:23:06 -08:00
Aaron Turon
a27fbac868 Revise std::thread API to join by default
This commit is part of a series that introduces a `std::thread` API to
replace `std::task`.

In the new API, `spawn` returns a `JoinGuard`, which by default will
join the spawned thread when dropped. It can also be used to join
explicitly at any time, returning the thread's result. Alternatively,
the spawned thread can be explicitly detached (so no join takes place).

As part of this change, Rust processes now terminate when the main
thread exits, even if other detached threads are still running, moving
Rust closer to standard threading models. This new behavior may break code
that was relying on the previously implicit join-all.

In addition to the above, the new thread API also offers some built-in
support for building blocking abstractions in user space; see the module
doc for details.

Closes #18000

[breaking-change]
2014-12-18 23:31:52 -08:00
Tshepang Lekhonkhobe
652a9acb73 doc: mailing list is deprecated 2014-12-18 00:38:57 +02:00
Alex Crichton
42dbee098b rollup merge of #19930: cllns/lowercase-if
On the [guide site](http://doc.rust-lang.org/guide.html#if) I was confused when I got to "5 If". It looked like "5 LF" in lowercase.

Changing the if to lowercase solves this problem. I know titles are all capitalized, but I think it makes sense in this case to keep it lowercase, since `if` is a reserved word. I'd also be open to making it ```    `if`   ``` but I'm not sure how that would look on the site.

Before:
![screen shot 2014-12-16 at 12 58 01](https://cloud.githubusercontent.com/assets/632942/5458866/cb34c006-8523-11e4-89ef-3a3964bcedfc.png)
After:
![screen shot 2014-12-16 at 12 58 14](https://cloud.githubusercontent.com/assets/632942/5458865/cb33c444-8523-11e4-8d95-d377ed583ed6.png)
2014-12-17 11:50:30 -08:00
Alex Crichton
cd07efd264 rollup merge of #19873: drewm1980/master
In US english, "that" is used in restrictive clauses in place of
"which", and often affects the meaning of sentences.

In UK english and many dialects, no distinction is
made.

While Rust devs want to avoid unproductive pedanticism, it is worth at
least being uniform in documentation such as:

http://doc.rust-lang.org/std/iter/index.html

and also in cases where correct usage of US english clarifies the
sentence.
2014-12-17 11:50:28 -08:00
Alex Crichton
bfb5f8b931 rollup merge of #19743: steveklabnik/gh16143
This will hopefully help people with their first steps in Rust.

Fixes #16143.

/cc @jvns
2014-12-17 11:50:23 -08:00
Tshepang Lekhonkhobe
bada7df64b doc: remove extraneous line 2014-12-17 21:27:04 +02:00
Sean Collins
73d395e6db Change 'if' to lowercase, so it displays better on the site 2014-12-16 13:55:34 -05:00
bors
92e9e70d15 auto merge of #19882 : steveklabnik/rust/fix_download, r=nikomatsakis
Thank you, @Ap0ph1s.
2014-12-15 19:12:44 +00:00
Steve Klabnik
bd776b5090 Fix windows download links
Thank you, @Ap0ph1s.
2014-12-15 09:55:56 -05:00
Brian Anderson
42f4d636fa rollup merge of #19714: steveklabnik/gh16219
These should be properly annotated instead.

Fixes #16219.
2014-12-15 06:44:21 -08:00
Andrew Wagner
8fcc832198 Standardize some usages of "which" in docstrings
In US english, "that" is used in restrictive clauses in place of
"which", and often affects the meaning of sentences.

In UK english and many dialects, no distinction is
made.

While Rust devs want to avoid unproductive pedanticism, it is worth at
least being uniform in documentation such as:

http://doc.rust-lang.org/std/iter/index.html

and also in cases where correct usage of US english clarifies the
sentence.
2014-12-15 10:50:42 +01:00
Niko Matsakis
112faabf94 Update guide/intro to take into account the removal of proc.
cc @steveklabnick
2014-12-14 04:21:57 -05:00
Steve Klabnik
31b240d6bc Add comments with type annotations.
This will hopefully help people with their first steps in Rust.

Fixes #16143.
2014-12-11 15:45:47 -05:00
Steve Klabnik
3c9d8983be Fix up some {ignore} and {notrust}s
These should be properly annotated instead.

Fixes #16219.
2014-12-10 15:14:18 -05:00
Alex Crichton
1a61fe4280 Test fixes and rebase conflicts from the rollup 2014-12-09 10:26:04 -08:00
Alex Crichton
a2e9c99a66 rollup merge of #19616: steveklabnik/gh19556
Closes #19556.
2014-12-09 09:25:06 -08:00
Alex Crichton
fb587f1f9b rollup merge of #19614: steveklabnik/gh19599
Fixes #19599
2014-12-09 09:25:04 -08:00
Alex Crichton
a09632f7cb rollup merge of #19576: nhoss2/master
There was a link to a non existing guide
2014-12-09 09:24:38 -08:00
Steve Klabnik
e294772072 Add enum namespacing to the Guide.
Closes #19556.
2014-12-07 07:55:30 -05:00
Steve Klabnik
8ba5605233 remove usage of notrust from the docs
Fixes #19599
2014-12-07 04:18:56 -05:00
Nafis
e1b77b0709 fix 404 2014-12-06 08:17:49 +10:00
Corey Richardson
39646d2ff6 rollup merge of #19526: steveklabnik/gh19402
Fixes #19402.
2014-12-05 10:07:49 -08:00
Corey Richardson
0fb040f4bd rollup merge of #19525: steveklabnik/guide_edits
Fixes #19335. (or at least, the actionable parts)
2014-12-05 10:07:48 -08:00
Corey Richardson
fb55cbda8d rollup merge of #19462: MatejLach/but-and_guide
Using `and` here instead of `but` sounds better to me, as but makes it sound like an item which is still under active development shouldn't normally require more testing, but this one does - or something like that :-)
@steveklabnik?
2014-12-05 10:07:04 -08:00
Steve Klabnik
010cbd011a Tasks aren't actually lightweight :frown:
Fixes #19402.
2014-12-04 11:43:22 -05:00
Steve Klabnik
f0f7a90068 Some small copy edits to the guide.
Fixes #19335.
2014-12-04 11:39:13 -05:00
Matej Lach
ebf22cbf6a replace 'but' with 'and' 2014-12-02 16:45:57 +00:00
Matej Lach
5bbe5d6d93 better wording 2014-12-02 13:40:18 +00:00
Matej Lach
d9a3ea88fc Fix a simple typo 2014-11-29 13:26:32 +00:00
Alex Crichton
62137b6d79 rollup merge of #19336: apasel422/guide
- `s/(left|right) hand/\1-hand/`
- `s/parenthesis/parentheses/`
- `s/unicode/Unicode/`
- `s/validly-encoded/validly encoded/`
2014-11-26 16:50:13 -08:00
Alex Crichton
52ca9523a5 rollup merge of #19313: steveklabnik/gh18844
Fixes #18844
2014-11-26 16:50:11 -08:00
Alex Crichton
935a39b3cd rollup merge of #19312: steveklabnik/gh19177 2014-11-26 16:50:10 -08:00
Alex Crichton
8790ab148b rollup merge of #19310: steveklabnik/gh19178
Fixes #19178
2014-11-26 16:49:49 -08:00
Andrew Paseltiner
b7520f595f fix errors in the guide
- `s/(left|right) hand/\1-hand/`
- `s/parenthesis/parentheses/`
- `s/unicode/Unicode/`
- `s/validly-encoded/validly encoded/`
2014-11-26 08:41:40 -05:00
Steve Klabnik
55853c532f We now support 64 bit Windows.
Fixes #18844
2014-11-25 11:43:05 -05:00
Steve Klabnik
8369a607ed add slice patterns to the guide
Fixes #19177.
2014-11-25 11:37:20 -05:00
Steve Klabnik
72beb1f885 Extra note about struct matching order
Fixes #19178
2014-11-25 11:31:49 -05:00
Steve Klabnik
d7b29a6ccd Make note that examples need a main()
Fixes #19199
2014-11-25 11:18:39 -05:00
bors
e197a2b0ac auto merge of #18140 : JelteF/rust-1/guide-fix, r=cmr
The reason given didn't make any sense when I read it when reading through the docs. I think this is more clear. Please let me know it is also more correct.
2014-11-23 13:51:47 +00:00
Jelte Fennema
17f9de387a Fix the reason for calling a file lib.rs 2014-11-23 14:43:22 +01:00
Jakub Bukaj
384f611aa9 rollup merge of #18968: danluu/guide_play
As-is, there's no indication that the code examples pop out into a window that runs on `play.rust-lang.org` until you mouse over them. I managed to get to section 4 of the guide before realizing you could do this since it didn't occur to me to mouse over the example text.

cc @rose since we went through the tutorial together and I think it wasn't obvious to her either.
2014-11-19 22:37:18 +01:00
Steven Fackler
3dcd215740 Switch to purely namespaced enums
This breaks code that referred to variant names in the same namespace as
their enum. Reexport the variants in the old location or alter code to
refer to the new locations:

```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
=>
```
pub use self::Foo::{A, B};

pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
or
```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = Foo::A;
}
```

[breaking-change]
2014-11-17 07:35:51 -08:00
Dan Luu
0f11eb5479 Guide: add a pointer to play.rust-lang.org and explain how to run the code examples. 2014-11-14 22:16:25 -06:00
Jeff Parsons
2df9a085bd Rogue 'panic' -> 'fail' in guide.
Should refer to handling panicking tasks like any other computation
that may _fail_, not any other computation that may _panic_.
2014-11-10 21:20:11 +11:00
mdinger
c39e9f3437 Reword &str coercion into viewing 2014-11-08 00:46:11 -05:00
Alex Crichton
3c81f33ada rollup merge of #18708 : qwitwa/master 2014-11-06 13:53:26 -08:00
qwitwa
31ce92d910 14.3 - helpfully implied code sample is broken
As a new user, I spent a while confused when flycheck told me the code sample I'd typed in was invalid. I ended up figuring out some of what comes after the code sample more painfully by myself because there was no indication that it was broken in the text beforehand. This one line change makes it clear that the code following it is an experiment that may not work rather than something to assume just works.
2014-11-06 19:25:00 +00:00
tshakah
00ae767609 Update guide.md
Corrected singular/plural reference to enums
2014-11-06 15:19:00 +00:00
Niko Matsakis
63718792df Update the guide examples and try not to leave user hanging as to what
this `&x` sigil is all about.
2014-11-05 11:29:15 -05:00
bors
ceeac26de8 auto merge of #18338 : chastell/rust/guide_pointer_fixes, r=alexcrichton
This removes some leftover line-numbering cruft from elided error examples and brings some minor clarifications.

I’m not super happy about the ‘we cannot have two mutable pointers that point to the same memory’ wording (to the best of my understanding we can’t even have one mutable and one immutable), but other attempts to word this were derailing the flow a bit too much.
2014-11-04 21:26:23 +00:00
Piotr Szotkowski
9be04d574a Guide: drop line-number cruft from elided error examples 2014-11-04 19:39:12 +01:00
Piotr Szotkowski
c7182ba997 Guide: minor clarifications for the Pointers part 2014-11-04 19:39:12 +01:00
bors
1b2ad7831f auto merge of #18497 : gamazeps/rust/enumsmatch, r=steveklabnik
Closes #18169
2014-11-04 16:16:28 +00:00
gamazeps
dc7c8da74b Guide: explains the enum/match relationship
Closes #18169
2014-11-04 13:47:53 +01:00
Alex Crichton
fff2b35a6e rollup merge of #18355 : chastell/guide_iterators_macros_unsafe_fixes 2014-11-03 15:29:13 -08:00
P1start
5bf9ef2122 Convert some notes to help messages
Closes #18126.
2014-11-02 16:12:23 +13:00
bors
fd53657484 auto merge of #18339 : chastell/rust/guide_pattern_fixes, r=nikomatsakis
I think it helps to show that the variables introduced in match blocks are indeed independent from the matched variable `x` (especially when `x` is still reachable inside those blocks and might be useful), so this renames them accordingly. Maybe some linter (or language-level warning?) will eventually warn about shadowing `x` in such cases. ;)

I’m not super happy about the matching-on-range example, as it’s too contrived (`e` and `x` are exactly the same here), but I couldn’t come up with something both simple and non-redundant.
2014-10-30 20:17:15 +00:00
bors
52c3fe9533 auto merge of #18377 : steveklabnik/rust/fix_wording_about_errors, r=nikomatsakis
see https://github.com/rust-lang/rust/pull/18176#discussion_r19374679

/cc @eddyb @huonw @nikomatsakis
2014-10-30 17:57:09 +00:00
Steve Klabnik
7828c3dd28 Rename fail! to panic!
https://github.com/rust-lang/rfcs/pull/221

The current terminology of "task failure" often causes problems when
writing or speaking about code. You often want to talk about the
possibility of an operation that returns a Result "failing", but cannot
because of the ambiguity with task failure. Instead, you have to speak
of "the failing case" or "when the operation does not succeed" or other
circumlocutions.

Likewise, we use a "Failure" header in rustdoc to describe when
operations may fail the task, but it would often be helpful to separate
out a section describing the "Err-producing" case.

We have been steadily moving away from task failure and toward Result as
an error-handling mechanism, so we should optimize our terminology
accordingly: Result-producing functions should be easy to describe.

To update your code, rename any call to `fail!` to `panic!` instead.
Assuming you have not created your own macro named `panic!`, this
will work on UNIX based systems:

    grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g'

You can of course also do this by hand.

[breaking-change]
2014-10-29 11:43:07 -04:00
bors
124508dea1 auto merge of #18340 : chastell/rust/guide_closures_fixes, r=steveklabnik
Some minor wording fixes to the Closures chapter; my brain tripped a few times when reading it, so I tried to come up with something a bit smoother. I’m not a native speaker, so please do review this critically.
2014-10-29 06:36:57 +00:00
Piotr Szotkowski
1bfe6a2a54 Guide: Iterators: …are always lazy + rewrap as per request 2014-10-28 20:24:02 +01:00
bors
d1bfd6515c auto merge of #18273 : gamazeps/rust/issue18218, r=steveklabnik
Closes #18218
2014-10-28 14:36:54 +00:00
Alex Crichton
a1d719dad4 rollup merge of #18347 : cakebaker/ffi 2014-10-27 15:12:47 -07:00
Alex Crichton
dac3234bba rollup merge of #18321 : chastell/guide_refresh_testing_output 2014-10-27 15:12:29 -07:00
Alex Crichton
54647bd317 rollup merge of #18320 : chastell/guide_simplify_formatting 2014-10-27 15:12:29 -07:00
Alex Crichton
0c736c7b1d rollup merge of #18309 : cakebaker/fix_off_by_one 2014-10-27 15:12:29 -07:00
Alex Crichton
da57aa57d4 rollup merge of #18231 : cakebaker/fix_greater_than_forty_two_closure 2014-10-27 12:53:01 -07:00
Steve Klabnik
13e4daee26 Fix some wording about errors
see https://github.com/rust-lang/rust/pull/18176#discussion_r19374679
2014-10-27 15:51:52 -04:00
John Kleint
d257b37608 Guide: motivate Box and Rc pointers with need, uses, benefits, and examples.
Explain that Rust has different pointer types because there is a
tradeoff between flexibility and efficiency. Motivate boxes as
fixed-size containers of variable-sized objects. Clarify that Box and Rc
are pointer types that you deref with * just like references. Stick to
explaining the semantics and avoid implementation details.  Scope isn't
the most accurate framework to think about deallocation (since you
return boxes and otherwise move values out of scopes); it's more "when
the value is done being used," i.e., lifetime. Provide a connection
between Rust's pointer types by locating them on a flexibiltiy /
performance scale. Explain the compiler can't statically analyze
lifetimes with multiple owners; hence the need for (runtime) reference
counting.
2014-10-26 23:41:51 -04:00
Piotr Szotkowski
56f1a67cc7 Guide: Iterators, Macros and Unsafe wording fixes 2014-10-26 22:27:43 +01:00
Piotr Szotkowski
16bae692be Guide: Closures fix suggested by @cakebaker 2014-10-26 18:15:08 +01:00
Daniel Hofstetter
622ae41e90 Guide: Add link to FFI explanation 2014-10-26 16:58:17 +01:00
Piotr Szotkowski
4eedd873ec Guide: Closures: minor wording fixes 2014-10-26 09:50:16 +01:00
Piotr Szotkowski
aa1cd6e707 Guide: Patterns: use non-x variables in match blocks 2014-10-26 09:41:50 +01:00
Piotr Szotkowski
eb903b4843 Guide: update Testing output and fix contents to match 2014-10-25 23:10:27 +02:00
Piotr Szotkowski
6a22454145 Guide: Cargo now adds bang and drops the semicolon for ‘Hello, world’ 2014-10-25 23:10:10 +02:00
Piotr Szotkowski
019a982f51 Guide: drop :d formatting where unnecessary 2014-10-25 22:50:38 +02:00
Daniel Hofstetter
122199909d Guide: Fix off-by-one error 2014-10-25 16:22:04 +02:00
bors
80e5fe1a56 auto merge of #18176 : jkleint/rust/guide-borrow-wording, r=steveklabnik
Explain the primary disadvantage of garbage collection is runtime
overhead and unpredictable pauses.  Elucidate where the name "race
condition" comes from.  Emphasize that Rust can guarantee your code is
free of race conditions and other memory errors, with no runtime
overhead.

cc @steveklabnik
2014-10-25 09:17:05 +00:00
gamazeps
b4697f0612 Changes a little the description of take in the guide
Closes #18218
2014-10-24 17:19:09 +02:00
P1start
ead6c4b9d4 Add a lint for not using field pattern shorthands
Closes #17792.
2014-10-24 15:44:18 +13:00
Daniel Hofstetter
cb5593a448 Guide: Change >= to > in closure 2014-10-22 16:16:05 +02:00
Daniel Hofstetter
88cf0b92dd Guide: Adapt range values to variable name 2014-10-22 15:32:28 +02:00
John Kleint
f0b7065e6f Guide: articulate the advantages of ownership over garbage collection.
Explain the primary disadvantage of garbage collection is runtime
overhead and unpredictable pauses.  Elucidate where the name "race
condition" comes from.  Emphasize that Rust can guarantee your code is
free of race conditions and other memory errors, with no runtime
overhead.
2014-10-21 09:09:32 -04:00
bors
6353465f4d auto merge of #18186 : cakebaker/rust/fix_test_count, r=alexcrichton 2014-10-20 17:57:39 +00:00
Daniel Hofstetter
555ab2b3a4 Guide: Fix test count 2014-10-20 16:17:59 +02:00
Daniel Hofstetter
cf3d3dc486 Guide: Fix typo in path 2014-10-20 15:26:09 +02:00
bors
c121cbab35 auto merge of #18139 : JelteF/rust-1/patch-1, r=steveklabnik
The explanation of fold talks about three elements that should be summed, but it uses different values in the provided code.
2014-10-19 13:52:06 +00:00
bors
4bb21f37ef auto merge of #18135 : EduardoBautista/rust/fix-misaligned-carot, r=steveklabnik 2014-10-19 07:17:15 +00:00
Jelte Fennema
2a668149c2 Fix fold explanation in the guide
The explanation of fold talks about three elements that should be summed, but it uses different values in the provided code.
2014-10-18 19:29:53 +02:00
Eduardo Bautista
cef0b55c78 Fix misaligned carot in guide 2014-10-18 01:34:50 -05:00
jrincayc
ce83a24b5f Use match expression directly in guide.md
Use a match expression directly in the println statement, instead of creating a second variable.
2014-10-17 07:00:29 -06:00
John Kleint
1ce5a5626e Guide: develop the exposition of arrays, vectors, and slices.
The array is the fundamental concept; vectors are growable arrays, and
slices are views into either.  Show common array ops up front: length
and iteration.  Mention arrays are immutable by default.  Highlight
definite initialization and bounds-checking as safety features.  Show
that you only need a type suffix on one element of initializers.
Explain that vectors are a value-add library type over arrays, not a
fundamental type; show they have the same "interface." Motivate slices
as efficient views into arrays; explain you can slice vectors, Strings,
&str because they're backed by arrays.
2014-10-14 23:23:57 -04:00