1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
use std::fmt; use crate::{Element, Number, Value}; impl fmt::Display for Number { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self { Number::Bit(x) => fmt::Display::fmt(x, f), Number::Unsigned8(x) => fmt::Display::fmt(x, f), Number::Signed8(x) => fmt::Display::fmt(x, f), Number::Unsigned16(x) => fmt::Display::fmt(x, f), Number::Signed16(x) => fmt::Display::fmt(x, f), Number::Unsigned32(x) => fmt::Display::fmt(x, f), Number::Signed32(x) => fmt::Display::fmt(x, f), Number::Unsigned64(x) => fmt::Display::fmt(x, f), Number::Signed64(x) => fmt::Display::fmt(x, f), Number::Unsigned128(x) => fmt::Display::fmt(x, f), Number::Signed128(x) => fmt::Display::fmt(x, f), Number::Float32(x) => fmt::Display::fmt(x, f), Number::Float64(x) => fmt::Display::fmt(x, f), } } } impl fmt::Display for Value { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self { Value::Null => f.write_str("null"), Value::Boolean(x) => fmt::Display::fmt(x, f), Value::String(x) => fmt::Display::fmt(x, f), Value::Char(x) => fmt::Display::fmt(x, f), Value::Number(x) => fmt::Display::fmt(x, f), Value::Bytes(x) => fmt::Debug::fmt(x, f), Value::UUID(x) => fmt::Display::fmt(x, f), } } } impl fmt::Display for Element { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self { Element::Unit => fmt::Debug::fmt(&(), f), Element::Value(x) => fmt::Display::fmt(x, f), Element::Option(x) => match x { Some(x) => { f.write_str("Some(")?; fmt::Display::fmt(x, f)?; f.write_str(")") }, None => f.write_str("None") } Element::Variant(n, x) => { f.write_str("\"")?; f.write_str(&n)?; f.write_str("\" { ")?; fmt::Display::fmt(x, f)?; f.write_str(" }") } Element::Struct(x) => fmt::Debug::fmt(x, f), Element::List(x) => fmt::Debug::fmt(x, f), Element::Array(_, x) => fmt::Debug::fmt(x, f), Element::Map(_, x) => fmt::Debug::fmt(x, f), Element::Compression(x) => fmt::Debug::fmt(x, f), } } }