mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 20:54:13 +00:00
c30b41012d
```rust reuse prefix::{a, b, c} ```
27 lines
447 B
Rust
27 lines
447 B
Rust
//@ check-pass
|
|
|
|
#![feature(fn_delegation)]
|
|
#![allow(incomplete_features)]
|
|
|
|
trait Trait {
|
|
fn foo(&self) -> u8 { 0 }
|
|
fn bar(&self) -> u8 { 1 }
|
|
}
|
|
|
|
impl Trait for u8 {}
|
|
|
|
struct S(u8);
|
|
|
|
// Macro expansion works inside delegation items.
|
|
macro_rules! u8 { () => { u8 } }
|
|
macro_rules! self_0 { () => { &self.0 } }
|
|
impl Trait for S {
|
|
reuse <u8!() as Trait>::{foo, bar} { self_0!() }
|
|
}
|
|
|
|
fn main() {
|
|
let s = S(2);
|
|
s.foo();
|
|
s.bar();
|
|
}
|