This commit is contained in:
nora 2022-09-15 23:13:16 +02:00
parent 55286e4b01
commit 44271dcd7b
5 changed files with 70 additions and 86 deletions

7
Cargo.lock generated
View file

@ -5,10 +5,3 @@ version = 3
[[package]] [[package]]
name = "aaaa" name = "aaaa"
version = "0.1.0" version = "0.1.0"
dependencies = [
"tower",
]
[[package]]
name = "tower"
version = "0.4.13"

View file

@ -6,4 +6,3 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
tower = { path = "./tower" }

View file

@ -1,3 +1,73 @@
trait Stream {
type Item;
}
trait TryStream: Stream {
type TryItem;
}
impl<S, T> TryStream for S
where
S: 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 = MS::Service;
}
pub fn broken<MS>(ms: MS)
where
MS: MakeService,
MS::Error: Into<()>,
{
// Error: Apparently Balance::new doesn't exist during MIR validation
let _ = Balance::<MS, ()>::new(ms);
}
fn main() { fn main() {
println!("Hello, world!"); println!("Hello, world!");
} }

View file

@ -1,9 +0,0 @@
[package]
name = "tower"
version = "0.4.13"
edition = "2018"
[features]
[dependencies]

View file

@ -1,69 +0,0 @@
trait Stream {
type Item;
}
trait TryStream: Stream {
type TryItem;
}
impl<S, T> TryStream for S
where
S: 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 = MS::Service;
}
pub fn broken<MS>(ms: MS)
where
MS: MakeService,
MS::Error: Into<()>,
{
// Error: Apparently Balance::new doesn't exist during MIR validation
let _ = Balance::<MS, ()>::new(ms);
}