Implement Display for FileHeaderSpec

This commit is contained in:
Matthias Beyer 2015-10-30 16:50:02 +01:00
parent 96ca9637d1
commit f9cc0e41ce

View file

@ -31,6 +31,27 @@ pub trait FileData : Sized {
fn get_abbrev(&self) -> String;
}
impl Display for FileHeaderSpec {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
match self {
&FileHeaderSpec::Null => write!(fmt, "NULL"),
&FileHeaderSpec::Bool => write!(fmt, "Bool"),
&FileHeaderSpec::Integer => write!(fmt, "Integer"),
&FileHeaderSpec::UInteger => write!(fmt, "UInteger"),
&FileHeaderSpec::Float => write!(fmt, "Float"),
&FileHeaderSpec::Text => write!(fmt, "Text"),
&FileHeaderSpec::Key{name: ref n, value_type: ref vt} => {
write!(fmt, "Key({:?}) -> {:?}", n, vt)
}
&FileHeaderSpec::Array{allowed_types: ref at} => {
write!(fmt, "Array({:?})", at)
}
}
}
}
pub struct MatchError {
summary: String,
path: Vec<FileHeaderSpec>,