use crate::{Location, Type};
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct FutureType {
pub inputs: Vec<Type>,
pub location: Option<Location>,
pub is_explicit: bool,
}
impl FutureType {
pub fn new(inputs: Vec<Type>, location: Option<Location>, is_explicit: bool) -> Self {
Self { inputs, location, is_explicit }
}
pub fn inputs(&self) -> &[Type] {
&self.inputs
}
pub fn location(&self) -> &Option<Location> {
&self.location
}
}
impl Default for crate::FutureType {
fn default() -> Self {
Self::new(vec![], None, false)
}
}
impl fmt::Display for crate::FutureType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Final<Fn({})>", self.inputs.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))
}
}
impl From<FutureType> for Type {
fn from(value: FutureType) -> Self {
Type::Future(value)
}
}