pub enum TypeExpr {
Primitive(TyLit),
Singleton(Literal),
Union(Vec<(Option<String>, TypeExpr)>),
Tuple(Vec<TupleElement>),
Array(Box<TypeExpr>),
Type,
}
Variants§
Primitive(TyLit)
Type of a built-in primitive type
Singleton(Literal)
Type that contains only a literal value
Union(Vec<(Option<String>, TypeExpr)>)
Union of sets (sum)
Tuple(Vec<TupleElement>)
Type of tuples (product)
Array(Box<TypeExpr>)
Type of arrays
Type
Type of sets. Used for exprs that can be converted to SetExpr and then used as a Ty.
Implementations§
source§impl TypeExpr
impl TypeExpr
sourcepub fn as_primitive_mut(&mut self) -> Option<&mut TyLit>
pub fn as_primitive_mut(&mut self) -> Option<&mut TyLit>
Optionally returns mutable references to the inner fields if this is a TypeExpr::Primitive
, otherwise None
sourcepub fn as_primitive(&self) -> Option<&TyLit>
pub fn as_primitive(&self) -> Option<&TyLit>
Optionally returns references to the inner fields if this is a TypeExpr::Primitive
, otherwise None
sourcepub fn into_primitive(self) -> Result<TyLit, Self>
pub fn into_primitive(self) -> Result<TyLit, Self>
Returns the inner fields if this is a TypeExpr::Primitive
, otherwise returns back the enum in the Err
case of the result
sourcepub fn as_singleton_mut(&mut self) -> Option<&mut Literal>
pub fn as_singleton_mut(&mut self) -> Option<&mut Literal>
Optionally returns mutable references to the inner fields if this is a TypeExpr::Singleton
, otherwise None
sourcepub fn as_singleton(&self) -> Option<&Literal>
pub fn as_singleton(&self) -> Option<&Literal>
Optionally returns references to the inner fields if this is a TypeExpr::Singleton
, otherwise None
sourcepub fn into_singleton(self) -> Result<Literal, Self>
pub fn into_singleton(self) -> Result<Literal, Self>
Returns the inner fields if this is a TypeExpr::Singleton
, otherwise returns back the enum in the Err
case of the result
sourcepub fn as_union_mut(&mut self) -> Option<&mut Vec<(Option<String>, TypeExpr)>>
pub fn as_union_mut(&mut self) -> Option<&mut Vec<(Option<String>, TypeExpr)>>
Optionally returns mutable references to the inner fields if this is a TypeExpr::Union
, otherwise None
sourcepub fn as_union(&self) -> Option<&Vec<(Option<String>, TypeExpr)>>
pub fn as_union(&self) -> Option<&Vec<(Option<String>, TypeExpr)>>
Optionally returns references to the inner fields if this is a TypeExpr::Union
, otherwise None
sourcepub fn into_union(self) -> Result<Vec<(Option<String>, TypeExpr)>, Self>
pub fn into_union(self) -> Result<Vec<(Option<String>, TypeExpr)>, Self>
Returns the inner fields if this is a TypeExpr::Union
, otherwise returns back the enum in the Err
case of the result
sourcepub fn as_tuple_mut(&mut self) -> Option<&mut Vec<TupleElement>>
pub fn as_tuple_mut(&mut self) -> Option<&mut Vec<TupleElement>>
Optionally returns mutable references to the inner fields if this is a TypeExpr::Tuple
, otherwise None
sourcepub fn as_tuple(&self) -> Option<&Vec<TupleElement>>
pub fn as_tuple(&self) -> Option<&Vec<TupleElement>>
Optionally returns references to the inner fields if this is a TypeExpr::Tuple
, otherwise None
sourcepub fn into_tuple(self) -> Result<Vec<TupleElement>, Self>
pub fn into_tuple(self) -> Result<Vec<TupleElement>, Self>
Returns the inner fields if this is a TypeExpr::Tuple
, otherwise returns back the enum in the Err
case of the result
sourcepub fn as_array_mut(&mut self) -> Option<&mut Box<TypeExpr>>
pub fn as_array_mut(&mut self) -> Option<&mut Box<TypeExpr>>
Optionally returns mutable references to the inner fields if this is a TypeExpr::Array
, otherwise None
sourcepub fn as_array(&self) -> Option<&Box<TypeExpr>>
pub fn as_array(&self) -> Option<&Box<TypeExpr>>
Optionally returns references to the inner fields if this is a TypeExpr::Array
, otherwise None
sourcepub fn into_array(self) -> Result<Box<TypeExpr>, Self>
pub fn into_array(self) -> Result<Box<TypeExpr>, Self>
Returns the inner fields if this is a TypeExpr::Array
, otherwise returns back the enum in the Err
case of the result