Skip to content

Commit

Permalink
Auto merge of #36019 - frewsxcv:take-into-inner, r=alexcrichton
Browse files Browse the repository at this point in the history
Introduce `into_inner` method on `std::io::Take`.

#23755
  • Loading branch information
bors authored Sep 13, 2016
2 parents fa9d8cc + ced1252 commit 09905b1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,33 @@ impl<T> Take<T> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn limit(&self) -> u64 { self.limit }

/// Consumes the `Take`, returning the wrapped reader.
///
/// # Examples
///
/// ```
/// #![feature(io_take_into_inner)]
///
/// use std::io;
/// use std::io::prelude::*;
/// use std::fs::File;
///
/// # fn foo() -> io::Result<()> {
/// let mut file = try!(File::open("foo.txt"));
///
/// let mut buffer = [0; 5];
/// let mut handle = file.take(5);
/// try!(handle.read(&mut buffer));
///
/// let file = handle.into_inner();
/// # Ok(())
/// # }
/// ```
#[unstable(feature = "io_take_into_inner", issue = "0")]
pub fn into_inner(self) -> T {
self.inner
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down

0 comments on commit 09905b1

Please sign in to comment.