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:
Steven Fackler
2017-05-14 21:29:18 -04:00
parent 445077963c
commit ecbb896b9e
28 changed files with 222 additions and 269 deletions

View File

@@ -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")]