Implement Display for meta::Integer and meta::Float

Those impls is pretty unambiguous I think.
This commit is contained in:
Lukas Kalbertodt
2021-07-24 16:11:12 +02:00
parent 066e7a0023
commit b663e698ba

View File

@@ -1,6 +1,8 @@
//! Types for [`Config::META`][super::Config::META]. Represent information about
//! a configuration type.
use core::fmt;
// TODO: having all these fields public make me uncomfortable. For now it's
// fine, but before reaching 1.0 I need to figure out how to allow future
// additions without breaking stuff.
@@ -63,3 +65,32 @@ pub enum Integer {
I128(i128),
Isize(isize),
}
impl fmt::Display for Float {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::F32(v) => v.fmt(f),
Self::F64(v) => v.fmt(f),
}
}
}
impl fmt::Display for Integer {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::U8(i) => i.fmt(f),
Self::U16(i) => i.fmt(f),
Self::U32(i) => i.fmt(f),
Self::U64(i) => i.fmt(f),
Self::U128(i) => i.fmt(f),
Self::Usize(i) => i.fmt(f),
Self::I8(i) => i.fmt(f),
Self::I16(i) => i.fmt(f),
Self::I32(i) => i.fmt(f),
Self::I64(i) => i.fmt(f),
Self::I128(i) => i.fmt(f),
Self::Isize(i) => i.fmt(f),
}
}
}