mirror of
https://github.com/Noratrieb/101844-repro.git
synced 2026-01-14 14:25:02 +01:00
77 lines
1.2 KiB
Rust
77 lines
1.2 KiB
Rust
trait Stream {
|
|
type Item;
|
|
}
|
|
|
|
trait TryStream: Stream {
|
|
type TryItem;
|
|
}
|
|
|
|
impl<S, T> TryStream for S
|
|
where
|
|
S: ?Sized + Stream<Item = T>,
|
|
{
|
|
type TryItem = T;
|
|
}
|
|
|
|
trait Discover {
|
|
type Service;
|
|
}
|
|
|
|
impl<S, D: ?Sized> Discover for D
|
|
where
|
|
D: TryStream<TryItem = S>,
|
|
{
|
|
type Service = S;
|
|
}
|
|
|
|
pub trait Service<Request> {
|
|
type Error;
|
|
}
|
|
|
|
pub trait MakeService {
|
|
type Error;
|
|
type Service: Service<(), Error = Self::Error>;
|
|
}
|
|
|
|
struct Balance<D, Req> {
|
|
_dreq: (D, Req),
|
|
}
|
|
|
|
impl<D, Req> Balance<D, Req>
|
|
where
|
|
D: Discover,
|
|
D::Service: Service<Req>,
|
|
<D::Service as Service<Req>>::Error: Into<()>,
|
|
{
|
|
fn new(_: D) -> Self {
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
impl<D, Req> Service<Req> for Balance<D, Req> {
|
|
type Error = ();
|
|
}
|
|
|
|
impl<MS> Stream for MS
|
|
where
|
|
MS: MakeService,
|
|
{
|
|
type Item = SvcWrap<MS::Service>;
|
|
}
|
|
|
|
pub fn broken<MS>()
|
|
where
|
|
MS: MakeService,
|
|
MS::Error: Into<()>,
|
|
{
|
|
let d: MS = todo!();
|
|
|
|
// Error: Apparently Balance::new doesn't exist during MIR validation
|
|
let _ = Balance::new(d);
|
|
}
|
|
|
|
struct SvcWrap<Svc>(Svc);
|
|
|
|
impl<Request, Svc: Service<Request>> Service<Request> for SvcWrap<Svc> {
|
|
type Error = Svc::Error;
|
|
}
|