@@ -1083,7 +1083,7 @@ pub trait Read {
1083
1083
/// let f = BufReader::new(File::open("foo.txt")?);
1084
1084
///
1085
1085
/// for byte in f.bytes() {
1086
- /// println!("{}", byte.unwrap() );
1086
+ /// println!("{}", byte? );
1087
1087
/// }
1088
1088
/// Ok(())
1089
1089
/// }
@@ -1995,15 +1995,16 @@ pub trait Seek {
1995
1995
/// .write(true)
1996
1996
/// .read(true)
1997
1997
/// .create(true)
1998
- /// .open("foo.txt").unwrap() ;
1998
+ /// .open("foo.txt")? ;
1999
1999
///
2000
2000
/// let hello = "Hello!\n";
2001
- /// write!(f, "{hello}").unwrap() ;
2002
- /// f.rewind().unwrap() ;
2001
+ /// write!(f, "{hello}")? ;
2002
+ /// f.rewind()? ;
2003
2003
///
2004
2004
/// let mut buf = String::new();
2005
- /// f.read_to_string(&mut buf).unwrap() ;
2005
+ /// f.read_to_string(&mut buf)? ;
2006
2006
/// assert_eq!(&buf, hello);
2007
+ /// # std::io::Result::Ok(())
2007
2008
/// ```
2008
2009
#[ stable( feature = "seek_rewind" , since = "1.55.0" ) ]
2009
2010
fn rewind ( & mut self ) -> Result < ( ) > {
@@ -2212,8 +2213,9 @@ fn skip_until<R: BufRead + ?Sized>(r: &mut R, delim: u8) -> Result<usize> {
2212
2213
///
2213
2214
/// let stdin = io::stdin();
2214
2215
/// for line in stdin.lock().lines() {
2215
- /// println!("{}", line.unwrap() );
2216
+ /// println!("{}", line? );
2216
2217
/// }
2218
+ /// # std::io::Result::Ok(())
2217
2219
/// ```
2218
2220
///
2219
2221
/// If you have something that implements [`Read`], you can use the [`BufReader`
@@ -2236,7 +2238,8 @@ fn skip_until<R: BufRead + ?Sized>(r: &mut R, delim: u8) -> Result<usize> {
2236
2238
/// let f = BufReader::new(f);
2237
2239
///
2238
2240
/// for line in f.lines() {
2239
- /// println!("{}", line.unwrap());
2241
+ /// let line = line?;
2242
+ /// println!("{line}");
2240
2243
/// }
2241
2244
///
2242
2245
/// Ok(())
@@ -2274,14 +2277,15 @@ pub trait BufRead: Read {
2274
2277
/// let stdin = io::stdin();
2275
2278
/// let mut stdin = stdin.lock();
2276
2279
///
2277
- /// let buffer = stdin.fill_buf().unwrap() ;
2280
+ /// let buffer = stdin.fill_buf()? ;
2278
2281
///
2279
2282
/// // work with buffer
2280
2283
/// println!("{buffer:?}");
2281
2284
///
2282
2285
/// // ensure the bytes we worked with aren't returned again later
2283
2286
/// let length = buffer.len();
2284
2287
/// stdin.consume(length);
2288
+ /// # std::io::Result::Ok(())
2285
2289
/// ```
2286
2290
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2287
2291
fn fill_buf ( & mut self ) -> Result < & [ u8 ] > ;
@@ -2327,12 +2331,13 @@ pub trait BufRead: Read {
2327
2331
/// let stdin = io::stdin();
2328
2332
/// let mut stdin = stdin.lock();
2329
2333
///
2330
- /// while stdin.has_data_left().unwrap() {
2334
+ /// while stdin.has_data_left()? {
2331
2335
/// let mut line = String::new();
2332
- /// stdin.read_line(&mut line).unwrap() ;
2336
+ /// stdin.read_line(&mut line)? ;
2333
2337
/// // work with line
2334
2338
/// println!("{line:?}");
2335
2339
/// }
2340
+ /// # std::io::Result::Ok(())
2336
2341
/// ```
2337
2342
#[ unstable( feature = "buf_read_has_data_left" , reason = "recently added" , issue = "86423" ) ]
2338
2343
fn has_data_left ( & mut self ) -> Result < bool > {
0 commit comments