| 1 | use std::fmt; |
| 2 | |
| 3 | use crate::{type_info::PyVariableInfo, TypeInfo}; |
| 4 | |
| 5 | #[derive (Debug, Clone, PartialEq)] |
| 6 | pub struct VariableDef { |
| 7 | pub name: &'static str, |
| 8 | pub type_: TypeInfo, |
| 9 | } |
| 10 | |
| 11 | impl From<&PyVariableInfo> for VariableDef { |
| 12 | fn from(info: &PyVariableInfo) -> Self { |
| 13 | Self { |
| 14 | name: info.name, |
| 15 | type_: (info.r#type)(), |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | impl fmt::Display for VariableDef { |
| 21 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 22 | write!(f, " {}: {}" , self.name, self.type_) |
| 23 | } |
| 24 | } |
| 25 | |