@@ -194,7 +194,7 @@ an error the task will fail.
194
194
If you wanted to handle the error though you might write
195
195
196
196
let mut error = None;
197
- do io_error::cond(|e: IoError| {
197
+ do io_error::cond.trap (|e: IoError| {
198
198
error = Some(e);
199
199
}).in {
200
200
File::new("diary.txt").write_line("met a girl");
@@ -498,10 +498,16 @@ pub trait Reader {
498
498
///
499
499
/// # Example
500
500
///
501
- /// let mut reader = BufferedReader::new(File::open(&Path::new("foo.txt")));
502
- /// for line in reader.lines() {
503
- /// println(line);
504
- /// }
501
+ /// ```rust
502
+ /// use std::io::buffered::BufferedReader;
503
+ /// use std::io::File;
504
+ /// # let _g = ::std::io::ignore_io_error();
505
+ ///
506
+ /// let mut reader = BufferedReader::new(File::open(&Path::new("foo.txt")));
507
+ /// println(reader.read_line().unwrap_or(~"Expected at least one line."));
508
+ ///
509
+ /// if reader.eof() { println("The file is only one line long."); }
510
+ /// ```
505
511
///
506
512
/// # Failure
507
513
///
@@ -1057,6 +1063,18 @@ pub trait Buffer: Reader {
1057
1063
/// encoded unicode codepoints. If a newline is encountered, then the
1058
1064
/// newline is contained in the returned string.
1059
1065
///
1066
+ /// # Example
1067
+ ///
1068
+ /// ```rust
1069
+ /// use std::io::buffered::BufferedReader;
1070
+ /// use std::io::stdin;
1071
+ /// # let _g = ::std::io::ignore_io_error();
1072
+ ///
1073
+ /// let mut reader = BufferedReader::new(std::io::stdin());
1074
+ ///
1075
+ /// let input = reader.read_line().unwrap_or(~"nothing");
1076
+ /// ```
1077
+ ///
1060
1078
/// # Failure
1061
1079
///
1062
1080
/// This function will raise on the `io_error` condition (except for
0 commit comments