You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/complement-cheatsheet.md
+14-3Lines changed: 14 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ let y: int = x.unwrap();
48
48
49
49
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.
50
50
51
-
~~~
51
+
~~~{.xfail-test}
52
52
use std::path::Path;
53
53
use std::io::fs::File;
54
54
@@ -63,6 +63,9 @@ Use the [`lines`](http://static.rust-lang.org/doc/master/std/io/trait.Buffer.htm
63
63
64
64
~~~
65
65
use std::io::buffered::BufferedReader;
66
+
# use std::io::mem::MemReader;
67
+
68
+
# let reader = MemReader::new(~[]);
66
69
67
70
let mut reader = BufferedReader::new(reader);
68
71
for line in reader.lines() {
@@ -149,6 +152,9 @@ Phantom types are useful for enforcing state at compile time. For example:
Attempting to close a closed door is prevented statically:
170
+
171
+
~~~{.xfail-test}
161
172
let _ = close(Door::<Closed>(~"front")); // error: mismatched types: expected `main::Door<main::Open>` but found `main::Door<main::Closed>`
162
173
~~~
163
174
@@ -185,7 +196,7 @@ Window* createWindow(int width, int height);
185
196
186
197
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:
0 commit comments