Add Read::initializer.
This is an API that allows types to indicate that they can be passed buffers of uninitialized memory which can improve performance.
This commit is contained in:
@@ -12,7 +12,7 @@ use io::prelude::*;
|
||||
|
||||
use core::convert::TryInto;
|
||||
use cmp;
|
||||
use io::{self, SeekFrom, Error, ErrorKind};
|
||||
use io::{self, Initializer, SeekFrom, Error, ErrorKind};
|
||||
|
||||
/// A `Cursor` wraps another type and provides it with a
|
||||
/// [`Seek`] implementation.
|
||||
@@ -229,6 +229,11 @@ impl<T> Read for Cursor<T> where T: AsRef<[u8]> {
|
||||
self.pos += n as u64;
|
||||
Ok(n)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn initializer(&self) -> Initializer {
|
||||
Initializer::nop()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
Reference in New Issue
Block a user