Skip to content

Rollup of 12 pull requests #34200

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 26 commits into from
Jun 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d6560dd
run rustfmt on map.rs in libcollections/btree folder
srinivasreddy Jun 5, 2016
27d4ed4
run rustfmt on librustc_bitflags folder
srinivasreddy Jun 5, 2016
75fc40c
Remove a gotcha from book/error-handling.md
jviide Jun 6, 2016
4504df7
Test case for borrowk ICE #25579
imjacobclark Jun 7, 2016
96c85f4
run rustfmt on libflate folder
srinivasreddy Jun 7, 2016
7abdbd4
docs: simplify wording
matklad Jun 7, 2016
0379493
Resolving build failure
imjacobclark Jun 7, 2016
d592675
Updated README to account for changes in MSYS2
seventh-chord Jun 8, 2016
4c5f3a6
Resolving line length build fail
imjacobclark Jun 8, 2016
92e8228
Fixed two little Game Of Thrones References
hoodie Jun 7, 2016
bc4def9
docs: Improve char::to_{lower,upper}case examples
ollie27 Jun 8, 2016
8180a91
Fix BTreeMap example typo
rwz Jun 9, 2016
300a5d7
fix indentation in README
euclio Jun 9, 2016
3dfc8c1
doc: intro should be 1 sentence
tshepang Jun 9, 2016
4f6e8f8
Rollup merge of #34088 - srinivasreddy:rustfmt_map.rs, r=nrc
sanxiyn Jun 10, 2016
b258197
Rollup merge of #34129 - jviide:from-string-box-error, r=steveklabnik
sanxiyn Jun 10, 2016
b694093
Rollup merge of #34136 - imjacobclark:ice-test-case-25579, r=nikomats…
sanxiyn Jun 10, 2016
06e069e
Rollup merge of #34145 - matklad:any-docs, r=steveklabnik
sanxiyn Jun 10, 2016
63bb68b
Rollup merge of #34146 - srinivasreddy:libflate_rustfmt, r=nagisa
sanxiyn Jun 10, 2016
493f149
Rollup merge of #34148 - srinivasreddy:bitflags_rustfmt, r=nagisa
sanxiyn Jun 10, 2016
e31210a
Rollup merge of #34159 - seventh-chord:master, r=alexcrichton
sanxiyn Jun 10, 2016
886df54
Rollup merge of #34160 - hoodie:bug/GoT_References, r=GuillaumeGomez
sanxiyn Jun 10, 2016
71b05c2
Rollup merge of #34165 - ollie27:docs_char_case, r=steveklabnik
sanxiyn Jun 10, 2016
e58c967
Rollup merge of #34175 - rwz:patch-2, r=alexcrichton
sanxiyn Jun 10, 2016
633b259
Rollup merge of #34184 - euclio:patch-1, r=steveklabnik
sanxiyn Jun 10, 2016
107d423
Rollup merge of #34185 - tshepang:shorten-paragraph, r=steveklabnik
sanxiyn Jun 10, 2016
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
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ build.
$ pacman -Sy pacman-mirrors
```

Download [MinGW from
here](http://mingw-w64.org/doku.php/download/mingw-builds), and choose the
`version=4.9.x,threads=win32,exceptions=dwarf/seh` flavor when installing. Also, make sure to install to a path without spaces in it. After installing,
add its `bin` directory to your `PATH`. This is due to [#28260](https://github.com/rust-lang/rust/issues/28260), in the future,
installing from pacman should be just fine.
Download [MinGW from
here](http://mingw-w64.org/doku.php/download/mingw-builds), and choose the
`version=4.9.x,threads=win32,exceptions=dwarf/seh` flavor when installing. Also, make sure to install to a path without spaces in it. After installing,
add its `bin` directory to your `PATH`. This is due to [#28260](https://github.com/rust-lang/rust/issues/28260), in the future,
installing from pacman should be just fine.

```
```sh
# Make git available in MSYS2 (if not already available on path)
$ pacman -S git

Expand All @@ -90,6 +90,8 @@ installing from pacman should be just fine.

3. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
MSYS2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.
(As of the latest version of MSYS2 you have to run `msys2_shell.cmd -mingw32`
or `msys2_shell.cmd -mingw64` from the command line instead)

4. Navigate to Rust's source code, configure and build it:

Expand Down
20 changes: 8 additions & 12 deletions src/doc/book/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ use std::error::Error;

fn search<P: AsRef<Path>>
(file_path: P, city: &str)
-> Result<Vec<PopulationCount>, Box<Error+Send+Sync>> {
-> Result<Vec<PopulationCount>, Box<Error>> {
let mut found = vec![];
let file = try!(File::open(file_path));
let mut rdr = csv::Reader::from_reader(file);
Expand Down Expand Up @@ -1858,20 +1858,17 @@ Instead of `x.unwrap()`, we now have `try!(x)`. Since our function returns a
`Result<T, E>`, the `try!` macro will return early from the function if an
error occurs.

There is one big gotcha in this code: we used `Box<Error + Send + Sync>`
instead of `Box<Error>`. We did this so we could convert a plain string to an
error type. We need these extra bounds so that we can use the
[corresponding `From`
impls](../std/convert/trait.From.html):
At the end of `search` we also convert a plain string to an error type
by using the [corresponding `From` impls](../std/convert/trait.From.html):

```rust,ignore
// We are making use of this impl in the code above, since we call `From::from`
// on a `&'static str`.
impl<'a, 'b> From<&'b str> for Box<Error + Send + Sync + 'a>
impl<'a> From<&'a str> for Box<Error>

// But this is also useful when you need to allocate a new string for an
// error message, usually with `format!`.
impl From<String> for Box<Error + Send + Sync>
impl From<String> for Box<Error>
```

Since `search` now returns a `Result<T, E>`, `main` should use case analysis
Expand Down Expand Up @@ -1964,7 +1961,7 @@ use std::io;

fn search<P: AsRef<Path>>
(file_path: &Option<P>, city: &str)
-> Result<Vec<PopulationCount>, Box<Error+Send+Sync>> {
-> Result<Vec<PopulationCount>, Box<Error>> {
let mut found = vec![];
let input: Box<io::Read> = match *file_path {
None => Box::new(io::stdin()),
Expand Down Expand Up @@ -2175,9 +2172,8 @@ heuristics!
`unwrap`. Be warned: if it winds up in someone else's hands, don't be
surprised if they are agitated by poor error messages!
* If you're writing a quick 'n' dirty program and feel ashamed about panicking
anyway, then use either a `String` or a `Box<Error + Send + Sync>` for your
error type (the `Box<Error + Send + Sync>` type is because of the
[available `From` impls](../std/convert/trait.From.html)).
anyway, then use either a `String` or a `Box<Error>` for your
error type.
* Otherwise, in a program, define your own error types with appropriate
[`From`](../std/convert/trait.From.html)
and
Expand Down
Loading