Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fmt;
- #[derive(Debug)]
- enum TagData {
- Int(i32),
- Float(f64),
- String(String),
- None,
- }
- impl fmt::Display for TagData {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- TagData::Int(i) => write!(f, "{}", i),
- TagData::Float(fl) => write!(f, "{}", fl),
- TagData::String(s) => write!(f, "{}", s),
- TagData::None => write!(f, "None")
- }
- }
- }
- fn main(){
- let d = TagData::Int(42);
- print!("{:?} vs {}", d, d);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement