Skip to content

Commit 7fe5025

Browse files
committed
---
yaml --- r: 97926 b: refs/heads/master c: 77ec044 h: refs/heads/master v: v3
1 parent 57b9759 commit 7fe5025

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: c2ef4e53722476afab906b7720fd5434ea929717
2+
refs/heads/master: 77ec04487b9e9c2673ed78c88beddd469d5de7b7
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b6400f998497c3958f40997a71756ead344a776d
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36

trunk/configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ do
806806
make_dir $h/test/doc-guide-container
807807
make_dir $h/test/doc-guide-tasks
808808
make_dir $h/test/doc-guide-conditions
809+
make_dir $h/test/doc-complement-cheatsheet
809810
make_dir $h/test/doc-rust
810811
done
811812

trunk/doc/complement-cheatsheet.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let y: int = x.unwrap();
4848

4949
Use [`File::open`](http://static.rust-lang.org/doc/master/std/io/fs/struct.File.html#method.open) to create a [`File`](http://static.rust-lang.org/doc/master/std/io/fs/struct.File.html) struct, which implements the [`Reader`](http://static.rust-lang.org/doc/master/std/io/trait.Reader.html) trait.
5050

51-
~~~
51+
~~~ {.xfail-test}
5252
use std::path::Path;
5353
use std::io::fs::File;
5454
@@ -63,6 +63,9 @@ Use the [`lines`](http://static.rust-lang.org/doc/master/std/io/trait.Buffer.htm
6363

6464
~~~
6565
use std::io::buffered::BufferedReader;
66+
# use std::io::mem::MemReader;
67+
68+
# let reader = MemReader::new(~[]);
6669
6770
let mut reader = BufferedReader::new(reader);
6871
for line in reader.lines() {
@@ -149,6 +152,9 @@ Phantom types are useful for enforcing state at compile time. For example:
149152
~~~
150153
struct Door<State>(~str);
151154
155+
struct Open;
156+
struct Closed;
157+
152158
fn close(Door(name): Door<Open>) -> Door<Closed> {
153159
Door::<Closed>(name)
154160
}
@@ -157,7 +163,12 @@ fn open(Door(name): Door<Closed>) -> Door<Open> {
157163
Door::<Open>(name)
158164
}
159165
160-
let _ = close(Door::<Open>(~"front")); // ok
166+
let _ = close(Door::<Open>(~"front"));
167+
~~~
168+
169+
Attempting to close a closed door is prevented statically:
170+
171+
~~~ {.xfail-test}
161172
let _ = close(Door::<Closed>(~"front")); // error: mismatched types: expected `main::Door<main::Open>` but found `main::Door<main::Closed>`
162173
~~~
163174

@@ -185,7 +196,7 @@ Window* createWindow(int width, int height);
185196

186197
You can use a zero-element `enum` ([phantom type](#how-do-i-express-phantom-types)) to represent the opaque object handle. The FFI would look like this:
187198

188-
~~~
199+
~~~ {.xfail-test}
189200
enum Window {}
190201
extern "C" {
191202
fn createWindow(width: c_int, height: c_int) -> *Window;

trunk/mk/tests.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
2222
# Markdown files under doc/ that should have their code extracted and run
2323
DOC_TEST_NAMES = tutorial guide-ffi guide-macros guide-lifetimes \
2424
guide-tasks guide-conditions guide-container guide-pointers \
25+
complement-cheatsheet \
2526
rust
2627

2728
######################################################################

0 commit comments

Comments
 (0)