Created
April 20, 2019 05:15
-
-
Save satellitex/18d12c236a0ba2076183c115d244c59d to your computer and use it in GitHub Desktop.
Trait を static 構造体みたいに使う。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait Trait<T: std::fmt::Debug> { | |
fn display(&self, t: T) { | |
println!("{:?}", t); | |
} | |
} | |
pub struct Dummy; | |
impl<T: std::fmt::Debug> Trait<T> for Dummy{} | |
fn main() { | |
<Trait<i32>>::display(&Dummy, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment