2016-08-05 15:18:01 -05:00
|
|
|
trait Generator {
|
|
|
|
fn create() -> u32;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Impl;
|
|
|
|
|
|
|
|
impl Generator for Impl {
|
|
|
|
fn create() -> u32 { 1 }
|
|
|
|
}
|
|
|
|
|
2021-01-15 07:33:51 -06:00
|
|
|
impl Impl {
|
|
|
|
fn new() -> Self {
|
|
|
|
Impl{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<u32> for Impl {
|
|
|
|
fn into(self) -> u32 { 1 }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo(bar: u32) {}
|
|
|
|
|
2016-08-05 15:18:01 -05:00
|
|
|
struct AnotherImpl;
|
|
|
|
|
|
|
|
impl Generator for AnotherImpl {
|
|
|
|
fn create() -> u32 { 2 }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2022-06-12 10:46:57 -05:00
|
|
|
let cont: u32 = Generator::create(); //~ ERROR E0790
|
2016-08-05 15:18:01 -05:00
|
|
|
}
|
2021-01-15 07:33:51 -06:00
|
|
|
|
|
|
|
fn buzz() {
|
|
|
|
let foo_impl = Impl::new();
|
|
|
|
let bar = foo_impl.into() * 1u32; //~ ERROR E0283
|
|
|
|
foo(bar);
|
|
|
|
}
|