2020-03-24 12:41:16 -05:00
|
|
|
// The duplicate macro will create a copy of the item with the given identifier.
|
2015-01-20 13:10:55 -06:00
|
|
|
|
2020-03-24 12:41:16 -05:00
|
|
|
// check-pass
|
|
|
|
// aux-build:duplicate.rs
|
2015-01-20 13:10:55 -06:00
|
|
|
|
2015-04-30 23:05:02 -05:00
|
|
|
#[macro_use]
|
2020-03-24 12:41:16 -05:00
|
|
|
extern crate duplicate;
|
2015-04-30 23:05:02 -05:00
|
|
|
|
2020-03-24 12:41:16 -05:00
|
|
|
#[duplicate(MyCopy)]
|
2015-01-20 13:10:55 -06:00
|
|
|
struct MyStruct {
|
2020-03-24 12:41:16 -05:00
|
|
|
number: i32,
|
2015-01-20 13:10:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
trait TestTrait {
|
2020-03-24 12:41:16 -05:00
|
|
|
#[duplicate(TestType2)]
|
2015-01-20 13:10:55 -06:00
|
|
|
type TestType;
|
|
|
|
|
2020-03-24 12:41:16 -05:00
|
|
|
#[duplicate(required_fn2)]
|
2015-01-20 13:10:55 -06:00
|
|
|
fn required_fn(&self);
|
|
|
|
|
2020-03-24 12:41:16 -05:00
|
|
|
#[duplicate(provided_fn2)]
|
|
|
|
fn provided_fn(&self) {}
|
2015-01-20 13:10:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl TestTrait for MyStruct {
|
2020-03-24 12:41:16 -05:00
|
|
|
#[duplicate(TestType2)]
|
2015-01-20 13:10:55 -06:00
|
|
|
type TestType = f64;
|
|
|
|
|
2020-03-24 12:41:16 -05:00
|
|
|
#[duplicate(required_fn2)]
|
|
|
|
fn required_fn(&self) {}
|
2015-01-20 13:10:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let s = MyStruct { number: 42 };
|
|
|
|
s.required_fn();
|
|
|
|
s.required_fn2();
|
|
|
|
s.provided_fn();
|
|
|
|
s.provided_fn2();
|
|
|
|
|
|
|
|
let s = MyCopy { number: 42 };
|
|
|
|
}
|