mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
23 lines
330 B
Rust
23 lines
330 B
Rust
|
pub trait X {
|
||
|
type InnerType;
|
||
|
fn my_method(&self) -> Self::InnerType;
|
||
|
}
|
||
|
|
||
|
pub struct MyTy<T> {
|
||
|
pub t: T,
|
||
|
}
|
||
|
|
||
|
impl X for MyTy<bool> {
|
||
|
type InnerType = bool;
|
||
|
fn my_method(&self) -> bool {
|
||
|
self.t
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl X for MyTy<u8> {
|
||
|
type InnerType = u8;
|
||
|
fn my_method(&self) -> u8 {
|
||
|
self.t
|
||
|
}
|
||
|
}
|