use crate::TypeKind;
use serde::Serialize;
use std::fmt;
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
pub struct VectorType {
pub element_type: Box<TypeKind>,
}
impl VectorType {
pub fn new(element: TypeKind) -> Self {
Self { element_type: Box::new(element) }
}
pub fn element_type(&self) -> &TypeKind {
&self.element_type
}
}
impl fmt::Display for VectorType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[{}]", self.element_type)
}
}
impl From<VectorType> for TypeKind {
fn from(value: VectorType) -> Self {
TypeKind::Vector(value)
}
}