mirror of
https://github.com/Noratrieb/101844-repro.git
synced 2026-01-14 14:25:02 +01:00
main
This commit is contained in:
parent
55286e4b01
commit
44271dcd7b
5 changed files with 70 additions and 86 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -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"
|
|
||||||
|
|
|
||||||
|
|
@ -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" }
|
|
||||||
70
src/main.rs
70
src/main.rs
|
|
@ -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!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "tower"
|
|
||||||
version = "0.4.13"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[features]
|
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue