use std::fmt::{Display, Formatter};
pub type ShadowConst = &'static str;
#[derive(Debug, Clone)]
pub struct ConstVal {
pub desc: String,
pub v: String,
pub t: ConstType,
}
impl ConstVal {
pub fn new<S: Into<String>>(desc: S) -> ConstVal {
ConstVal {
desc: desc.into(),
v: "".to_string(),
t: ConstType::Str,
}
}
pub fn new_bool<S: Into<String>>(desc: S) -> ConstVal {
ConstVal {
desc: desc.into(),
v: "true".to_string(),
t: ConstType::Bool,
}
}
pub fn new_slice<S: Into<String>>(desc: S) -> ConstVal {
ConstVal {
desc: desc.into(),
v: "".to_string(),
t: ConstType::Slice,
}
}
}
#[derive(Debug, Clone)]
pub enum ConstType {
Str,
Bool,
Slice,
}
impl Display for ConstType {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
ConstType::Str => write!(f, "&str"),
ConstType::Bool => write!(f, "bool"),
ConstType::Slice => write!(f, "&[u8]"),
}
}
}