Skip to content

Rollup of 15 pull requests #21530

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

Merged
merged 172 commits into from
Jan 23, 2015
Merged
Changes from 1 commit
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
a72bd69
added optional method chain indentations for emacs major mode
KOMON Dec 16, 2014
ac110df
Expand the section on closures in TRPL.
js-ojus Jan 13, 2015
3819c22
add a section on performance to collection docs
Gankra Jan 16, 2015
bd621f0
Project region bounds out of the trait when deciding whether a
nikomatsakis Jan 16, 2015
b7ef34d
Add regression test for #20971. Fixes #20791.
nikomatsakis Jan 16, 2015
1138579
Add regression test for #20797. Fixes #20797.
nikomatsakis Jan 16, 2015
fe0868b
Add regression tests for #20763. Fixes #20763.
nikomatsakis Jan 16, 2015
785176b
rustup: Don't attempt to download SHA if it exists
mkpankov Jan 15, 2015
618cf5f
Refine wording of Thread::panicking
nagisa Jan 17, 2015
a32249d
libsyntax: uint types to usize
pshc Jan 17, 2015
fa01251
rustc: print filename if file cannot be written
stepancheg Jan 18, 2015
d5c8365
libsyntax: rename functions from uint to usize
pshc Jan 17, 2015
7b4c508
rustdoc: Add Show impls to more clean types
tomjakubowski Jan 14, 2015
d47a113
Remove some dead code from rustc::middle::ty
tomjakubowski Jan 14, 2015
aaf595e
rustdoc: Separate associated types from methods
tomjakubowski Jan 14, 2015
e930aeb
rustdoc: Accept string source in core::run_core
tomjakubowski Jan 18, 2015
8224e0e
rustdoc: Add some re-exports
tomjakubowski Jan 18, 2015
159236a
rustdoc: Handle associated types on inlined impls
tomjakubowski Jan 18, 2015
23a553a
Improve the vec![...] macro with UFCS.
eddyb Jan 18, 2015
f7fe249
Remove associated_types gate from std::ops docs
steveklabnik Jan 18, 2015
e3d099d
Fix #21356
aochagavia Jan 18, 2015
c821e5c
Add test for issue #21356
aochagavia Jan 18, 2015
4347cbb
Error message fixes and removed explicit returns in example code
angst7 Jan 18, 2015
9293607
quick formatting fix
angst7 Jan 18, 2015
c034f4a
Make date of nightly in rustup match server TZ
estsauver Jan 17, 2015
7a24b3a
libsyntax: int => i32 in appropriate places
pshc Jan 17, 2015
5913374
libsyntax: int types -> isize
pshc Jan 18, 2015
3c32cd1
libsyntax: 0u -> 0us, 0i -> 0is
pshc Jan 18, 2015
2c2480d
Replace `0 as *const/mut T` with `ptr::null/null_mut()`
petrochenkov Jan 19, 2015
abccfa4
Impl Send for Timer on Windows
retep998 Jan 19, 2015
d2623f2
rt: Remove libtime wrappers
klutzy Jan 19, 2015
74e111c
impl Iterator for &mut Iterator and Box<Iterator>
Jan 19, 2015
8c3d914
Change the title of if statement in trpl book.
loganchien Jan 19, 2015
4968485
remove unnecessary parentheses from range notation
Jan 19, 2015
3c37a95
Updates of the fix
GuillaumeGomez Jan 19, 2015
e0eb3cc
Kill TraitStore
Jan 18, 2015
8e1e0f0
Remove onceness & bounds - they don't do anything.
Jan 18, 2015
ed769bf
Fix up some ‘help’ messages
ftxqxd Jan 20, 2015
d7b30f9
Remove ratchet-bench from configure.
ahmedcharles Jan 19, 2015
ec41785
Remove unsupported test features from compiletest.
ahmedcharles Jan 19, 2015
4f6f7e5
Remove unsupported test features from libtest.
ahmedcharles Jan 19, 2015
9400805
Initial support for aarch64-linux-android
ejjeong Jan 20, 2015
09d9924
librustc: hint close matches on accessing nonexisting fields
Jan 20, 2015
a729a40
Use assume to inform the optimiser about refcount invariants
Aatch Jan 20, 2015
849a38a
Avoid suggesting traits multiple times.
huonw Jan 20, 2015
01d7b8c
Correct small typos in map.rs.
Jan 20, 2015
f2b8404
prettier Buffer::read_until
Jan 16, 2015
1f50542
docs: typo
Jan 20, 2015
953f294
rustc: Remove deprecated flags
alexcrichton Jan 20, 2015
953d6df
Make error code registration work again. #19624
brson Jan 16, 2015
0c5225c
Add error codes to rustc_typeck
brson Jan 17, 2015
f68029e
Make fatal errors work with codes, add to typeck
brson Jan 18, 2015
cf629e7
Add error codes to resolve
brson Jan 18, 2015
9f59f7e
Add error codes to rustc
brson Jan 19, 2015
9a4401f
Add some extended errors.
michaelsproul Jan 18, 2015
b6380f5
Kill RacyCell in favor of marking SyncSender explicitly Send.
taralx Jan 20, 2015
9bbfd68
Add assumptions that the pointer is non-null
Aatch Jan 20, 2015
64914d9
rustc: Remove deprecated lint names
alexcrichton Jan 20, 2015
a7525bc
Add more explanation for why the assumes are there
Aatch Jan 20, 2015
ace2f09
alloc::boxed: enable test
stepancheg Jan 20, 2015
cd631c6
Register snapshot for 9006c3c
flaper87 Jan 20, 2015
8051bd0
Changed rust-mode code for tabs -> spaces
KOMON Jan 20, 2015
876b266
Make multiline errors work with codes
brson Jan 20, 2015
00cddb0
also forward Iterator::size_hint()
Jan 20, 2015
9714d3c
tests: uncomment regression tests for 13970, 13971, 13972
emberian Jan 20, 2015
1f6eb34
docs: Update for clarity
alfiedotwtf Jan 21, 2015
2cc7feb
implement `ExactSizeIterator` for `slice::{Chunks,ChunksMut}`
apasel422 Jan 12, 2015
eb08650
Display negative trait implementations correctly in rustdoc
Diggsey Jan 21, 2015
ed56c15
remove `NoSendItem` and `NoSyncItem`
Jan 19, 2015
3cb9fa2
std: Rename Show/String to Debug/Display
alexcrichton Jan 20, 2015
f5e093f
Remove write_metric_diff and supporting code.
ahmedcharles Jan 19, 2015
72ae518
Remove compare_to_old().
ahmedcharles Jan 20, 2015
eb00913
Remove ratchet().
ahmedcharles Jan 20, 2015
a55ef3a
debuginfo: Make debuginfo source location assignment more stable (Pt. 1)
michaelwoerister Dec 11, 2014
d4ced7b
De-mut the parser
sanxiyn Jan 21, 2015
53edd76
Remove feature(import_shadowing).
eddyb Dec 20, 2014
38ac9e3
syntax: merge ast::ViewItem into ast::Item.
eddyb Dec 23, 2014
7cece87
syntax: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Jan 13, 2015
e389ab1
rustc_back: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Dec 23, 2014
cfb63d5
rustc: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Dec 23, 2014
9370ae1
rustc_typeck: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Dec 23, 2014
c91761e
rustc_trans: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Dec 23, 2014
7dbefce
rustc_driver: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Dec 23, 2014
f83a972
rustc_resolve: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Dec 23, 2014
3102b9e
rustdoc: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Dec 26, 2014
838b2ea
docs: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Dec 26, 2014
fba0bf6
Stabilize Index traits and most range notation
aturon Jan 16, 2015
092ba6a
Deprecate slicing methods in favor of notation
aturon Jan 18, 2015
a506d4c
Fallout from stabilization.
aturon Jan 18, 2015
da8023d
Change init-large-type to use child thread
aturon Jan 21, 2015
29e5d8d
Improve quality of String#to_slice() deprecation message
steveklabnik Jan 14, 2015
83af23e
rollup merge of #19913: KOMON/rust-mode-emacs-indentation
alexcrichton Jan 21, 2015
2e9adab
rollup merge of #21053: apasel422/exact
alexcrichton Jan 21, 2015
550255d
rollup merge of #21138: mkpankov/master
alexcrichton Jan 21, 2015
89b2e23
rollup merge of #21157: steveklabnik/deprecation
alexcrichton Jan 21, 2015
41890bf
rollup merge of #21274: estsauver/21270
alexcrichton Jan 21, 2015
b250d9a
rollup merge of #21289: brson/errorcodes
alexcrichton Jan 21, 2015
5da2538
rollup merge of #21333: stepancheg/trans-write-diag
alexcrichton Jan 21, 2015
0c98187
rollup merge of #21340: pshc/libsyntax-no-more-ints
alexcrichton Jan 21, 2015
5123f75
rollup merge of #21342: Diggsey/issue-21310
alexcrichton Jan 21, 2015
0447721
rollup merge of #21354: eddyb/vec-ufcs
alexcrichton Jan 21, 2015
ecc9dcc
rollup merge of #21367: steveklabnik/remove_gate
alexcrichton Jan 21, 2015
5fda9bc
rollup merge of #21368: tomjakubowski/rustdoc-miscellany
alexcrichton Jan 21, 2015
9173797
rollup merge of #21372: arielb1/remove-the-box
alexcrichton Jan 21, 2015
8b10733
rollup merge of #21389: retep998/timer
alexcrichton Jan 21, 2015
ad2c3e8
rollup merge of #21391: klutzy/rt-time-cleanup
alexcrichton Jan 21, 2015
9227db3
rollup merge of #21392: japaric/iter
alexcrichton Jan 21, 2015
e4434f9
rollup merge of #21393: loganchien/fix-if-stmt-doc-title
alexcrichton Jan 21, 2015
4b6a056
rollup merge of #21394: japaric/nonono
alexcrichton Jan 21, 2015
1646707
rollup merge of #21396: japaric/no-parens-in-range
alexcrichton Jan 21, 2015
5d82c0f
rollup merge of #21411: P1start/help-tweaks
alexcrichton Jan 21, 2015
81504f2
rollup merge of #21413: ahmedcharles/remove-test-features
alexcrichton Jan 21, 2015
a6780d8
rollup merge of #21414: ejjeong/aarch64-linux-android
alexcrichton Jan 21, 2015
229243c
rollup merge of #21418: Aatch/assume-refcount
alexcrichton Jan 21, 2015
e4e9a27
rollup merge of #21419: Toby-S/patch-1
alexcrichton Jan 21, 2015
bf77f6c
rollup merge of #21421: huonw/one-suggestion-per-trait
alexcrichton Jan 21, 2015
9ef5484
rollup merge of #21423: oli-obk/prettier_read_until
alexcrichton Jan 21, 2015
28937be
rollup merge of #21429: GuillaumeGomez/macro-fix
alexcrichton Jan 21, 2015
de89dc8
rollup merge of #21433: alfie/typobook
alexcrichton Jan 21, 2015
04a2255
rollup merge of #21437: FlaPer87/snapshot
alexcrichton Jan 21, 2015
2783807
rollup merge of #21438: taralx/kill-racycell
alexcrichton Jan 21, 2015
b5de833
rollup merge of #21441: alexcrichton/rustc-opts
alexcrichton Jan 21, 2015
907db6c
rollup merge of #21444: petrochenkov/null
alexcrichton Jan 21, 2015
efea645
rollup merge of #21446: stepancheg/boxed-test
alexcrichton Jan 21, 2015
e4b81d2
rollup merge of #21447: cmr/master
alexcrichton Jan 21, 2015
87c3ee8
rollup merge of #21457: alexcrichton/issue-21436
alexcrichton Jan 21, 2015
79708e6
rollup merge of #21462: ahmedcharles/remove-ratchet
alexcrichton Jan 21, 2015
9c999c7
rollup merge of #21463: sanxiyn/demut
alexcrichton Jan 21, 2015
3a44107
debuginfo: Fix issue with associated types and struct fields
michaelwoerister Jan 21, 2015
973c2f6
Explain that RefCell is single-threaded.
steveklabnik Jan 21, 2015
139346a
tests: fix fallout of merging ast::ViewItem into ast::Item.
eddyb Dec 26, 2014
652445f
Added some tests for arbitrary ordered view items
Kimundi Jan 2, 2015
5e07f5a
Added another test with success local-item shadowing
eddyb Jan 13, 2015
2d17a33
Deny imports after non-item statements.
eddyb Jan 13, 2015
4ffde08
Test fixes and rebase conflicts
alexcrichton Jan 21, 2015
537889a
Fix type inference problems in tests and docs
aturon Jan 21, 2015
626db33
Move regression test for #20971 into run-fail, since it panics.
nikomatsakis Jan 21, 2015
f4df69a
rollup merge of #20642: michaelwoerister/sane-source-locations-pt1
alexcrichton Jan 21, 2015
036d8c4
rollup merge of #21252: nikomatsakis/assoc-type-ice-hunt-take-2
alexcrichton Jan 21, 2015
886c6f3
rollup merge of #21258: aturon/stab-3-index
alexcrichton Jan 21, 2015
bbbdd10
Improve RwLock::new's docs
steveklabnik Jan 21, 2015
df1cddf
rollup merge of #20179: eddyb/blind-items
alexcrichton Jan 21, 2015
23da54d
Move rustdoc.md into the book
steveklabnik Jan 21, 2015
ecbee2e
More test fixes and rebase conflicts
alexcrichton Jan 21, 2015
ee253c9
Revert "Add more explanation for why the assumes are there"
alexcrichton Jan 21, 2015
e6f85c2
Revert "Add assumptions that the pointer is non-null"
alexcrichton Jan 21, 2015
91cec5b
Revert "Use assume to inform the optimiser about refcount invariants"
alexcrichton Jan 21, 2015
22d2387
add doc examples for connect/concat
steveklabnik Jan 21, 2015
a2936a3
Make compiletest set an environment variable so that on Windows 32-bi…
ColonelJ Jan 22, 2015
90af723
Make diagnostic ordering deterministic
alexcrichton Jan 21, 2015
5d2056a
Auto merge of #21473 - alexcrichton:rollup, r=alexcrichton
bors Jan 22, 2015
48aa068
powerpc: Fix liblibc
richo Jan 22, 2015
b7930d9
Auto merge of #21187 - oli-obk:feature/hint_struct_field_access, r=al…
bors Jan 22, 2015
8160fc4
Auto merge of #21078 - js-ojus:master, r=steveklabnik
bors Jan 22, 2015
42cbd7a
Reference correct fn during lifetime ellision
SeanTAllen Jan 22, 2015
cef8295
Return the String guide to its former glory.
steveklabnik Jan 12, 2015
5a3bded
Beef up docs for Box<T>
steveklabnik Jan 22, 2015
d1c7ae4
Rollup merge of #21056 - steveklabnik:return_strings, r=sfackler
steveklabnik Jan 22, 2015
c76ce8c
Rollup merge of #21091 - steveklabnik:add_attribute_docs, r=huonw
steveklabnik Jan 22, 2015
4db64bd
Rollup merge of #21217 - Gankro:docadoca, r=steveklabnik
steveklabnik Jan 22, 2015
3364d41
Rollup merge of #21325 - nagisa:thread-panicking, r=steveklabnik
steveklabnik Jan 22, 2015
5f71c22
Rollup merge of #21373 - angst7:pointer_doc_1, r=steveklabnik
steveklabnik Jan 22, 2015
1644978
Rollup merge of #21450 - alfie:book2, r=steveklabnik
steveklabnik Jan 22, 2015
07fb31a
Rollup merge of #21471 - michaelwoerister:associated-types, r=alexcri…
steveklabnik Jan 22, 2015
0b793ea
Rollup merge of #21472 - steveklabnik:gh21469, r=huonw
steveklabnik Jan 22, 2015
22ed381
Rollup merge of #21477 - steveklabnik:gh21440, r=alexcrichton
steveklabnik Jan 22, 2015
aa874ab
Rollup merge of #21479 - steveklabnik:rustdoc_to_book, r=alexcrichton
steveklabnik Jan 22, 2015
acd044c
Rollup merge of #21484 - steveklabnik:connect_docs, r=alexcrichton
steveklabnik Jan 22, 2015
dc27d29
Rollup merge of #21496 - ColonelJ:paatch, r=alexcrichton
steveklabnik Jan 22, 2015
bb80310
Rollup merge of #21500 - richo:power-fixups, r=alexcrichton
steveklabnik Jan 22, 2015
b994a3e
Rollup merge of #21516 - steveklabnik:document_box, r=alexcrichton
steveklabnik Jan 22, 2015
9fb672b
Rollup merge of #21517 - SeanTAllen:master, r=steveklabnik
steveklabnik Jan 22, 2015
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
Prev Previous commit
Next Next commit
Expand the section on closures in TRPL.
* Include an illustration of a function that accepts two closures.
  • Loading branch information
js-ojus committed Jan 13, 2015
commit ac110df0ff52c3ae93d98bc75ec08b99d7d205b5
43 changes: 35 additions & 8 deletions src/doc/trpl/closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,7 @@ fn twice<F: Fn(i32) -> i32>(x: i32, f: F) -> i32 {
arguments. `x` is an `i32`, we've done that a ton of times. `f` is a function,
though, and that function takes an `i32` and returns an `i32`. This is
what the requirement `Fn(i32) -> i32` for the type parameter `F` says.
You might ask yourself: why do we need to introduce a type parameter here?
That is because in Rust each closure has its own unique type.
So, not only do closures with different signatures have different types,
but different closures with the *same* signature have *different* types!
You can think of it this way: the behaviour of a closure is part of its type.
And since we want to support many different closures that all take
an `i32` and return an `i32` we introduced a type parameter that is able
to represent all these closures.
Now `F` represents *any* function that takes an `i32` and returns an `i32`.

This is the most complicated function signature we've seen yet! Give it a read
a few times until you can see how it works. It takes a teeny bit of practice, and
Expand Down Expand Up @@ -181,6 +174,40 @@ fn main() {

Doing this is not particularly common, but it's useful every once in a while.

Before we move on, let us look at a function that accepts two closures.

```{rust}
fn compose<F, G>(x: i32, f: F, g: G) -> i32
where F: Fn(i32) -> i32, G: Fn(i32) -> i32 {
g(f(x))
}

fn main() {
compose(5,
|&: n: i32| { n + 42 },
|&: n: i32| { n * 2 }); // evaluates to 94
}
```

You might ask yourself: why do we need to introduce two type
parameters `F` and `G` here? Evidently, both `f` and `g` have the
same signature: `Fn(i32) -> i32`.

That is because in Rust each closure has its own unique type.
So, not only do closures with different signatures have different types,
but different closures with the *same* signature have *different*
types, as well!

You can think of it this way: the behavior of a closure is part of its
type. Therefore, using a single type parameter for both closures
will accept the first of them, rejecting the second. The distinct
type of the second closure does not allow it to be represented by the
same type parameter as that of the first. We acknowledge this, and
use two different type parameters `F` and `G`.

This also introduces the `where` clause, which lets us describe type
parameters in a more flexible manner.

That's all you need to get the hang of closures! Closures are a little bit
strange at first, but once you're used to them, you'll miss them
in other languages. Passing functions to other functions is
Expand Down