display for primitive types
This commit is contained in:
parent
ce7bef559b
commit
2ccddaf20d
|
@ -1,4 +1,4 @@
|
|||
use std::collections::BTreeMap;
|
||||
use std::{collections::BTreeMap, fmt::Display};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -204,6 +204,25 @@ pub enum PrimitiveType {
|
|||
Custom(String),
|
||||
}
|
||||
|
||||
impl Display for PrimitiveType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
PrimitiveType::Bool { .. } => f.write_str("bool"),
|
||||
PrimitiveType::U8 => f.write_str("u8"),
|
||||
PrimitiveType::U16 => f.write_str("u16"),
|
||||
PrimitiveType::U32 => f.write_str("u32"),
|
||||
PrimitiveType::U64 => f.write_str("u64"),
|
||||
PrimitiveType::I8 => f.write_str("i8"),
|
||||
PrimitiveType::I16 => f.write_str("i16"),
|
||||
PrimitiveType::I32 => f.write_str("i32"),
|
||||
PrimitiveType::I64 => f.write_str("i64"),
|
||||
PrimitiveType::F32 => f.write_str("f32"),
|
||||
PrimitiveType::F64 => f.write_str("f64"),
|
||||
PrimitiveType::Custom(custom) => f.write_str(&custom),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum Type {
|
||||
Ptr(Box<Type>),
|
||||
|
|
Loading…
Reference in a new issue