File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -1755,6 +1755,35 @@ impl<T> Take<T> {
17551755 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
17561756 pub fn limit ( & self ) -> u64 { self . limit }
17571757
1758+ /// Sets the number of bytes that can be read before this instance will
1759+ /// return EOF. This is the same as constructing a new `Take` instance, so
1760+ /// the amount of bytes read and the previous limit value don't matter when
1761+ /// calling this method.
1762+ ///
1763+ /// # Examples
1764+ ///
1765+ /// ```
1766+ /// #![feature(take_set_limit)]
1767+ /// use std::io;
1768+ /// use std::io::prelude::*;
1769+ /// use std::fs::File;
1770+ ///
1771+ /// # fn foo() -> io::Result<()> {
1772+ /// let f = File::open("foo.txt")?;
1773+ ///
1774+ /// // read at most five bytes
1775+ /// let mut handle = f.take(5);
1776+ /// handle.set_limit(10);
1777+ ///
1778+ /// assert_eq!(handle.limit(), 10);
1779+ /// # Ok(())
1780+ /// # }
1781+ /// ```
1782+ #[ unstable( feature = "take_set_limit" , issue = "42781" ) ]
1783+ pub fn set_limit ( & mut self , limit : u64 ) {
1784+ self . limit = limit;
1785+ }
1786+
17581787 /// Consumes the `Take`, returning the wrapped reader.
17591788 ///
17601789 /// # Examples
You can’t perform that action at this time.
0 commit comments