use std::borrow::Cow;
use crate::{DataType, NamedDataType};
#[derive(Debug, Clone, PartialEq)]
pub struct TupleType {
pub(crate) elements: Vec<DataType>,
}
impl TupleType {
pub fn to_anonymous(self) -> DataType {
DataType::Tuple(self)
}
pub fn to_named(self, name: impl Into<Cow<'static, str>>) -> NamedDataType {
NamedDataType {
name: name.into(),
docs: Cow::Borrowed(""),
deprecated: None,
ext: None,
inner: DataType::Tuple(self),
}
}
pub fn elements(&self) -> &Vec<DataType> {
&self.elements
}
}
impl From<TupleType> for DataType {
fn from(t: TupleType) -> Self {
t.to_anonymous()
}
}