From 8779d291ecb5debb74698de187440c42a37b9c33 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Thu, 15 Sep 2022 21:55:02 +0200 Subject: [PATCH] more --- tower/tower/src/discover.rs | 2 +- tower/tower/src/lib.rs | 11 +---------- tower/tower/src/macros.rs | 28 ---------------------------- tower/tower/src/make.rs | 22 ++++++++++++++++++---- 4 files changed, 20 insertions(+), 43 deletions(-) delete mode 100644 tower/tower/src/macros.rs diff --git a/tower/tower/src/discover.rs b/tower/tower/src/discover.rs index f8e3e83..9cfa2a3 100644 --- a/tower/tower/src/discover.rs +++ b/tower/tower/src/discover.rs @@ -1,4 +1,4 @@ -use crate::sealed::Sealed; +use crate::Sealed; use futures_core::TryStream; use std::{ pin::Pin, diff --git a/tower/tower/src/lib.rs b/tower/tower/src/lib.rs index 05c18bd..21093a4 100644 --- a/tower/tower/src/lib.rs +++ b/tower/tower/src/lib.rs @@ -1,18 +1,10 @@ // #![allow(warnings)] -#[macro_use] -pub(crate) mod macros; pub mod balance; - pub mod discover; - pub mod make; - -#[allow(unreachable_pub)] -mod sealed { - pub trait Sealed {} -} +pub trait Sealed {} /// Alias for a type-erased error type. pub type BoxError = Box; @@ -24,7 +16,6 @@ mod load { } } - use std::future::Future; use std::task::{Context, Poll}; diff --git a/tower/tower/src/macros.rs b/tower/tower/src/macros.rs deleted file mode 100644 index 1d3722e..0000000 --- a/tower/tower/src/macros.rs +++ /dev/null @@ -1,28 +0,0 @@ -macro_rules! opaque_future { - ($(#[$m:meta])* pub type $name:ident<$($param:ident),+> = $actual:ty;) => { - $(#[$m])* - pub struct $name<$($param),+> { - inner: $actual - } - - - impl<$($param),+> $name<$($param),+> { - pub(crate) fn new(inner: $actual) -> Self { - Self { - inner - } - } - } - - impl<$($param),+> std::future::Future for $name<$($param),+> - where - $actual: std::future::Future, - { - type Output = <$actual as std::future::Future>::Output; - #[inline] - fn poll(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll { - todo!() - } - } - } -} diff --git a/tower/tower/src/make.rs b/tower/tower/src/make.rs index 3a69372..d1309f0 100644 --- a/tower/tower/src/make.rs +++ b/tower/tower/src/make.rs @@ -1,6 +1,6 @@ //! Trait aliases for Services that produce specific types of Responses. -use crate::sealed::Sealed; +use crate::Sealed; use crate::Service; use std::task::{Context, Poll}; @@ -27,9 +27,23 @@ where } } -opaque_future! { - /// Response future from [`Shared`] services. - pub type SharedFuture = futures_util::future::Ready>; +pub struct SharedFuture { + _s: S, +} + +impl std::future::Future for SharedFuture +where + futures_util::future::Ready>: std::future::Future, +{ + type Output = + > as std::future::Future>::Output; + + fn poll( + self: std::pin::Pin<&mut Self>, + cx: &mut std::task::Context<'_>, + ) -> std::task::Poll { + todo!() + } } pub trait MakeService {