use crate::{generate::*, type_info::*, TypeInfo};
use std::{collections::HashSet, fmt};
#[derive(Debug, Clone, PartialEq)]
pub struct MemberDef {
pub name: &'static str,
pub r#type: TypeInfo,
}
impl Import for MemberDef {
fn import(&self) -> HashSet<ModuleRef> {
self.r#type.import.clone()
}
}
impl From<&MemberInfo> for MemberDef {
fn from(info: &MemberInfo) -> Self {
Self {
name: info.name,
r#type: (info.r#type)(),
}
}
}
impl fmt::Display for MemberDef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let indent = indent();
writeln!(f, "{indent}{}: {}", self.name, self.r#type)
}
}