Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. use std::fmt;
  2.  
  3. #[derive(Debug)]
  4. enum TagData {
  5. Int(i32),
  6. Float(f64),
  7. String(String),
  8. None,
  9. }
  10.  
  11. impl fmt::Display for TagData {
  12. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  13. match self {
  14. TagData::Int(i) => write!(f, "{}", i),
  15. TagData::Float(fl) => write!(f, "{}", fl),
  16. TagData::String(s) => write!(f, "{}", s),
  17. TagData::None => write!(f, "None")
  18. }
  19. }
  20. }
  21.  
  22. fn main(){
  23. let d = TagData::Int(42);
  24. print!("{:?} vs {}", d, d);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement