use crate::Type;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct VectorType {
pub element_type: Box<Type>,
}
impl VectorType {
pub fn new(element: Type) -> Self {
Self { element_type: Box::new(element) }
}
pub fn element_type(&self) -> &Type {
&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 Type {
fn from(value: VectorType) -> Self {
Type::Vector(value)
}
}