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
use std::cell::RefCell; use std::collections::HashMap; pub type ShadowConst = &'static str; pub trait ShadowGen { fn gen_const(&self) -> HashMap<ShadowConst, ConstVal>; } #[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) -> RefCell<ConstVal> { RefCell::new(ConstVal { desc: desc.into(), v: "".to_string(), t: ConstType::OptStr, }) } } #[derive(Debug, Clone)] pub enum ConstType { OptStr, Str, } impl ToString for ConstType { fn to_string(&self) -> String { match self { ConstType::OptStr => "Option<&str>".to_string(), ConstType::Str => "&str".to_string(), } } }