Official docs about [Phantom Type & Data](https://doc.rust-lang.org/rust-by-example/generics/phantom/testcase_units.html) # Example ```rust #![allow(unused)] use std::marker::PhantomData; use std::fmt::{Display, Formatter, Result}; use std::any::type_name; enum Sec {} enum Min {} struct Duration { value: i32, unit: PhantomData, } impl Duration { fn new(value: i32) -> Duration { Duration { value: value, unit: PhantomData } } } impl Display for Duration { fn fmt(&self, f: &mut Formatter) -> Result { write!( f, "{} {}", self.value, type_name::(), ) } } fn print_second(sec: Duration) { println!("Printed: {}", sec); } fn main() { // ok, rust compiler will imply that // Duration::new(1) is with unit sec print_second(Duration::new(1)); let duration_min = Duration::::new(10); // compile time error! type mismatch // print_second(duration_min); } ```