Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::marker::PhantomData;
- trait Cons {
- const PI: f32;
- }
- struct Vague;
- impl Cons for Vague {
- const PI: f32 = 3.14;
- }
- struct Outer<T: Cons>(PhantomData<T>);
- impl<T: Cons> Outer<T> {
- fn pi(&self) -> f32 {
- T::PI
- }
- }
- fn main() {
- let x = Outer::<Vague>(PhantomData);
- println!("{}", x.pi());
- }
Add Comment
Please, Sign In to add comment