mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
27 lines
411 B
Rust
27 lines
411 B
Rust
//@ check-pass
|
|
|
|
trait Factory {
|
|
type Product;
|
|
}
|
|
|
|
impl Factory for () {
|
|
type Product = ();
|
|
}
|
|
|
|
trait ProductConsumer<P> {
|
|
fn consume(self, product: P);
|
|
}
|
|
|
|
impl<P> ProductConsumer<P> for () {
|
|
fn consume(self, _: P) {}
|
|
}
|
|
|
|
fn make_product_consumer<F: Factory>(_: F) -> impl ProductConsumer<F::Product> {
|
|
()
|
|
}
|
|
|
|
fn main() {
|
|
let consumer = make_product_consumer(());
|
|
consumer.consume(());
|
|
}
|