pub struct Type {
pub kind: TypeKind,
pub nullable: bool,
}Available on crate feature
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 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.
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Forget for Type
impl Freeze for Type
impl Move for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnsafeUnpin for Type
impl UnwindSafe for Type
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more