chore(lib): add dyn keyword to trait objects (#1820)

Requires Rust 1.27.
This commit is contained in:
Sean McArthur
2019-06-03 13:08:13 -07:00
committed by GitHub
parent e0f5a9c6c5
commit 01c03db7ea
28 changed files with 107 additions and 94 deletions

View File

@@ -26,7 +26,7 @@ use common::io::Rewind;
/// Alternatively, if the exact type is known, this can be deconstructed
/// into its parts.
pub struct Upgraded {
io: Rewind<Box<Io + Send>>,
io: Rewind<Box<dyn Io + Send>>,
}
/// A future for a possible HTTP upgrade.
@@ -85,7 +85,7 @@ pub(crate) trait Io: AsyncRead + AsyncWrite + 'static {
}
}
impl Io + Send {
impl dyn Io + Send {
fn __hyper_is<T: Io>(&self) -> bool {
let t = TypeId::of::<T>();
self.__hyper_type_id() == t
@@ -95,7 +95,7 @@ impl Io + Send {
if self.__hyper_is::<T>() {
// Taken from `std::error::Error::downcast()`.
unsafe {
let raw: *mut Io = Box::into_raw(self);
let raw: *mut dyn Io = Box::into_raw(self);
Ok(Box::from_raw(raw as *mut T))
}
} else {
@@ -109,7 +109,7 @@ impl<T: AsyncRead + AsyncWrite + 'static> Io for T {}
// ===== impl Upgraded =====
impl Upgraded {
pub(crate) fn new(io: Box<Io + Send>, read_buf: Bytes) -> Self {
pub(crate) fn new(io: Box<dyn Io + Send>, read_buf: Bytes) -> Self {
Upgraded {
io: Rewind::new_buffered(io, read_buf),
}