Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Refresh with latest book (as of June 2th) #36

Merged
merged 12 commits into from
Jun 2, 2016
Merged
115 changes: 94 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ This repository contains stuff to convert [this book](http://doc.rust-lang.org/b
Install:

- pandoc
- Rust and cargo (nightly for regex macros)
- XeLaTeX and probably some additional packages, I had to install (`sudo tlmgr install $pkg`) those:
- Rust and cargo
- XeLaTeX, up to date (`sudo tlmgr update -all`) and probably some additional packages (`sudo tlmgr install $pkg`) such as:
+ framed
+ hyphenat
+ quotchap
+ collection-fontsrecommended
- the DejaVu Sans Mono font: http://dejavu-fonts.org/
- the IPA font for Japanese Text: http://ipafont.ipa.go.jp/ipaexfont/download.html#en

Then run:

```sh
$ cargo run
$ cargo run --release
```

Voilà!
Expand Down
10 changes: 8 additions & 2 deletions lib/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
\usepackage{booktabs}
\usepackage[htt]{hyphenat}

\usepackage{amssymb}

% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
Expand Down Expand Up @@ -53,9 +55,13 @@
pdfborder={0 0 0}}
\urlstyle{same} % don't use monospace font for urls

\renewcommand*{\hyperref}[2][\ar]{%
\renewcommand*{\hypertarget}[3][\ar]{%
\def\ar{#2}%
#2 (\autoref{#1}, page~\pageref{#1})}
\label{#1}%
#3}

\renewcommand*{\hyperlink}[2]{%
#2 (\autoref{#1}, page~\pageref{#1})}

\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
Expand Down
10 changes: 5 additions & 5 deletions nomicon/atomics.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
% Atomics

Rust pretty blatantly just inherits C11's memory model for atomics. This is not
due this model being particularly excellent or easy to understand. Indeed, this
model is quite complex and known to have [several flaws][C11-busted]. Rather, it
is a pragmatic concession to the fact that *everyone* is pretty bad at modeling
atomics. At very least, we can benefit from existing tooling and research around
C.
due to this model being particularly excellent or easy to understand. Indeed,
this model is quite complex and known to have [several flaws][C11-busted].
Rather, it is a pragmatic concession to the fact that *everyone* is pretty bad
at modeling atomics. At very least, we can benefit from existing tooling and
research around C.

Trying to fully explain the model in this book is fairly hopeless. It's defined
in terms of madness-inducing causality graphs that require a full book to
Expand Down
4 changes: 2 additions & 2 deletions nomicon/casts.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ For numeric casts, there are quite a few cases to consider:
* zero-extend if the source is unsigned
* sign-extend if the source is signed
* casting from a float to an integer will round the float towards zero
* **[NOTE: currently this will cause Undefined Behaviour if the rounded
* **[NOTE: currently this will cause Undefined Behavior if the rounded
value cannot be represented by the target integer type][float-int]**.
This includes Inf and NaN. This is a bug and will be fixed.
* casting from an integer to float will produce the floating point
Expand All @@ -61,7 +61,7 @@ For numeric casts, there are quite a few cases to consider:
* casting from an f32 to an f64 is perfect and lossless
* casting from an f64 to an f32 will produce the closest possible value
(rounding strategy unspecified)
* **[NOTE: currently this will cause Undefined Behaviour if the value
* **[NOTE: currently this will cause Undefined Behavior if the value
is finite but larger or smaller than the largest or smallest finite
value representable by f32][float-float]**. This is a bug and will
be fixed.
Expand Down
2 changes: 1 addition & 1 deletion nomicon/coercions.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn main() {
```

```text
<anon>:10:5: 10:8 error: the trait `Trait` is not implemented for the type `&mut i32` [E0277]
<anon>:10:5: 10:8 error: the trait bound `&mut i32 : Trait` is not satisfied [E0277]
<anon>:10 foo(t);
^~~
```
2 changes: 1 addition & 1 deletion nomicon/concurrency.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Concurrency and Paralellism
% Concurrency and Parallelism

Rust as a language doesn't *really* have an opinion on how to do concurrency or
parallelism. The standard library exposes OS threads and blocking sys-calls
Expand Down
21 changes: 9 additions & 12 deletions nomicon/destructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ boilerplate" to drop children. If a struct has no special logic for being
dropped other than dropping its children, then it means `Drop` doesn't need to
be implemented at all!

**There is no stable way to prevent this behaviour in Rust 1.0.**
**There is no stable way to prevent this behavior in Rust 1.0.**

Note that taking `&mut self` means that even if you could suppress recursive
Drop, Rust will prevent you from e.g. moving fields out of self. For most types,
Expand All @@ -26,12 +26,11 @@ this is totally fine.
For instance, a custom implementation of `Box` might write `Drop` like this:

```rust
#![feature(alloc, heap_api, core_intrinsics, unique)]
#![feature(alloc, heap_api, drop_in_place, unique)]

extern crate alloc;

use std::ptr::Unique;
use std::intrinsics::drop_in_place;
use std::ptr::{drop_in_place, Unique};
use std::mem;

use alloc::heap;
Expand All @@ -53,17 +52,16 @@ impl<T> Drop for Box<T> {

and this works fine because when Rust goes to drop the `ptr` field it just sees
a [Unique] that has no actual `Drop` implementation. Similarly nothing can
use-after-free the `ptr` because when drop exits, it becomes inacessible.
use-after-free the `ptr` because when drop exits, it becomes inaccessible.

However this wouldn't work:

```rust
#![feature(alloc, heap_api, core_intrinsics, unique)]
#![feature(alloc, heap_api, drop_in_place, unique)]

extern crate alloc;

use std::ptr::Unique;
use std::intrinsics::drop_in_place;
use std::ptr::{drop_in_place, Unique};
use std::mem;

use alloc::heap;
Expand Down Expand Up @@ -101,7 +99,7 @@ After we deallocate the `box`'s ptr in SuperBox's destructor, Rust will
happily proceed to tell the box to Drop itself and everything will blow up with
use-after-frees and double-frees.

Note that the recursive drop behaviour applies to all structs and enums
Note that the recursive drop behavior applies to all structs and enums
regardless of whether they implement Drop. Therefore something like

```rust
Expand Down Expand Up @@ -137,12 +135,11 @@ The classic safe solution to overriding recursive drop and allowing moving out
of Self during `drop` is to use an Option:

```rust
#![feature(alloc, heap_api, core_intrinsics, unique)]
#![feature(alloc, heap_api, drop_in_place, unique)]

extern crate alloc;

use std::ptr::Unique;
use std::intrinsics::drop_in_place;
use std::ptr::{drop_in_place, Unique};
use std::mem;

use alloc::heap;
Expand Down
2 changes: 1 addition & 1 deletion nomicon/drop-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ y = x; // y was init; Drop y, overwrite it, and make x uninit!
// x goes out of scope; x was uninit; do nothing.
```

Similarly, branched code where all branches have the same behaviour with respect
Similarly, branched code where all branches have the same behavior with respect
to initialization has static drop semantics:

```rust
Expand Down
Loading