pub struct Type {
pub kind: TypeKind,
pub nullable: bool,
}parse only.Expand description
A type expression with nullability.
Fields§
§kind: TypeKindThe type expression
nullable: boolWhether this type is nullable
Implementations§
Source§impl Type
impl Type
Sourcepub fn parse(source: &str) -> Result<Self, ExtensionTypeError>
pub fn parse(source: &str) -> Result<Self, ExtensionTypeError>
Parse a type declaration, retaining variables and derivations without evaluation.
Sourcepub fn visit_references(&self, on_ext: &mut impl FnMut(&str))
pub fn visit_references(&self, on_ext: &mut impl FnMut(&str))
Visit extension type references, including those nested in parameters.
Sourcepub fn new(kind: TypeKind, nullable: bool) -> Type
pub fn new(kind: TypeKind, nullable: bool) -> Type
Create a type expression with the given nullability.
Sourcepub fn extension(name: String, nullable: bool) -> Type
pub fn extension(name: String, nullable: bool) -> Type
Create a new extension type reference (without parameters)
Sourcepub fn extension_with_params(
name: String,
parameters: Vec<TypeParameter>,
nullable: bool,
) -> Type
pub fn extension_with_params( name: String, parameters: Vec<TypeParameter>, nullable: bool, ) -> Type
Create a new parameterized extension type
Sourcepub fn struct(field_types: Vec<Type>, nullable: bool) -> Type
pub fn struct(field_types: Vec<Type>, nullable: bool) -> Type
Create a new struct type (ordered fields without names)
Sourcepub fn named_struct(fields: IndexMap<String, Type>, nullable: bool) -> Type
pub fn named_struct(fields: IndexMap<String, Type>, nullable: bool) -> Type
Create a new named struct type (nstruct - ordered fields with names)
Sourcepub fn is_concrete(&self) -> bool
pub fn is_concrete(&self) -> bool
Returns whether this type contains no unresolved variables.
Sourcepub fn is_compatible_with(&self, other: &Type) -> bool
pub fn is_compatible_with(&self, other: &Type) -> bool
Check if this type (as a function argument) is compatible with another type (as an input).
Does not bind type variables or symbolic parameters. Mainly checks nullability:
i64?is compatible withi64andi64?- both can be passed as argumentsi64is compatible withi64but NOTi64?- you can’t pass a nullable type to a function that only accepts non-nullable arguments
Trait Implementations§
Source§impl Display for Type
Formats full extension-YAML spellings, not function-signature short names.
impl Display for Type
Formats full extension-YAML spellings, not function-signature short names.