mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-06 05:33:59 +00:00
42 lines
728 B
Rust
42 lines
728 B
Rust
// The duplicate macro will create a copy of the item with the given identifier.
|
|
|
|
// check-pass
|
|
// aux-build:duplicate.rs
|
|
|
|
#[macro_use]
|
|
extern crate duplicate;
|
|
|
|
#[duplicate(MyCopy)]
|
|
struct MyStruct {
|
|
number: i32,
|
|
}
|
|
|
|
trait TestTrait {
|
|
#[duplicate(TestType2)]
|
|
type TestType;
|
|
|
|
#[duplicate(required_fn2)]
|
|
fn required_fn(&self);
|
|
|
|
#[duplicate(provided_fn2)]
|
|
fn provided_fn(&self) {}
|
|
}
|
|
|
|
impl TestTrait for MyStruct {
|
|
#[duplicate(TestType2)]
|
|
type TestType = f64;
|
|
|
|
#[duplicate(required_fn2)]
|
|
fn required_fn(&self) {}
|
|
}
|
|
|
|
fn main() {
|
|
let s = MyStruct { number: 42 };
|
|
s.required_fn();
|
|
s.required_fn2();
|
|
s.provided_fn();
|
|
s.provided_fn2();
|
|
|
|
let s = MyCopy { number: 42 };
|
|
}
|