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

@@ -98,7 +98,7 @@ pub struct Handshake<T, B> {
pub struct ResponseFuture {
// for now, a Box is used to hide away the internal `B`
// that can be returned if canceled
inner: Box<Future<Item=Response<Body>, Error=::Error> + Send>,
inner: Box<dyn Future<Item=Response<Body>, Error=::Error> + Send>,
}
/// Deconstructed parts of a `Connection`.
@@ -464,7 +464,7 @@ impl Builder {
/// Provide an executor to execute background HTTP2 tasks.
pub fn executor<E>(&mut self, exec: E) -> &mut Builder
where
E: Executor<Box<Future<Item=(), Error=()> + Send>> + Send + Sync + 'static,
E: Executor<Box<dyn Future<Item=(), Error=()> + Send>> + Send + Sync + 'static,
{
self.exec = Exec::Executor(Arc::new(exec));
self

View File

@@ -184,7 +184,7 @@ impl fmt::Debug for GaiAddrs {
}
#[derive(Clone)]
struct GaiExecutor(Arc<Executor<GaiTask> + Send + Sync>);
struct GaiExecutor(Arc<dyn Executor<GaiTask> + Send + Sync>);
impl Executor<oneshot::Execute<GaiBlocking>> for GaiExecutor {
fn execute(&self, future: oneshot::Execute<GaiBlocking>) -> Result<(), ExecuteError<oneshot::Execute<GaiBlocking>>> {

View File

@@ -27,7 +27,7 @@ pub trait Connect: Send + Sync {
/// The connected IO Stream.
type Transport: AsyncRead + AsyncWrite + Send + 'static;
/// An error occured when trying to connect.
type Error: Into<Box<StdError + Send + Sync>>;
type Error: Into<Box<dyn StdError + Send + Sync>>;
/// A Future that will resolve to the connected Transport.
type Future: Future<Item=(Self::Transport, Connected), Error=Self::Error> + Send;
/// Connect to a destination.
@@ -53,7 +53,7 @@ pub struct Connected {
pub(super) extra: Option<Extra>,
}
pub(super) struct Extra(Box<ExtraInner>);
pub(super) struct Extra(Box<dyn ExtraInner>);
#[derive(Clone, Copy, Debug, PartialEq)]
pub(super) enum Alpn {
@@ -344,7 +344,7 @@ impl fmt::Debug for Extra {
}
trait ExtraInner: Send + Sync {
fn clone_box(&self) -> Box<ExtraInner>;
fn clone_box(&self) -> Box<dyn ExtraInner>;
fn set(&self, res: &mut Response<::Body>);
}
@@ -358,7 +358,7 @@ impl<T> ExtraInner for ExtraEnvelope<T>
where
T: Clone + Send + Sync + 'static
{
fn clone_box(&self) -> Box<ExtraInner> {
fn clone_box(&self) -> Box<dyn ExtraInner> {
Box::new(self.clone())
}
@@ -367,7 +367,7 @@ where
}
}
struct ExtraChain<T>(Box<ExtraInner>, T);
struct ExtraChain<T>(Box<dyn ExtraInner>, T);
impl<T: Clone> Clone for ExtraChain<T> {
fn clone(&self) -> Self {
@@ -379,7 +379,7 @@ impl<T> ExtraInner for ExtraChain<T>
where
T: Clone + Send + Sync + 'static
{
fn clone_box(&self) -> Box<ExtraInner> {
fn clone_box(&self) -> Box<dyn ExtraInner> {
Box::new(self.clone())
}

View File

@@ -583,11 +583,11 @@ impl<C, B> fmt::Debug for Client<C, B> {
/// This is returned by `Client::request` (and `Client::get`).
#[must_use = "futures do nothing unless polled"]
pub struct ResponseFuture {
inner: Box<Future<Item=Response<Body>, Error=::Error> + Send>,
inner: Box<dyn Future<Item=Response<Body>, Error=::Error> + Send>,
}
impl ResponseFuture {
fn new(fut: Box<Future<Item=Response<Body>, Error=::Error> + Send>) -> Self {
fn new(fut: Box<dyn Future<Item=Response<Body>, Error=::Error> + Send>) -> Self {
Self {
inner: fut,
}
@@ -1030,7 +1030,7 @@ impl Builder {
/// Provide an executor to execute background `Connection` tasks.
pub fn executor<E>(&mut self, exec: E) -> &mut Self
where
E: Executor<Box<Future<Item=(), Error=()> + Send>> + Send + Sync + 'static,
E: Executor<Box<dyn Future<Item=(), Error=()> + Send>> + Send + Sync + 'static,
{
self.conn_builder.executor(exec);
self