pub enum Type<N: TreeNode = SyntaxNode> {
Map(MapType<N>),
Array(ArrayType<N>),
Pair(PairType<N>),
Object(ObjectType<N>),
Ref(TypeRef<N>),
Primitive(PrimitiveType<N>),
}Expand description
Represents a type.
Variants§
Map(MapType<N>)
The type is a map.
Array(ArrayType<N>)
The type is an array.
Pair(PairType<N>)
The type is a pair.
Object(ObjectType<N>)
The type is an object.
Ref(TypeRef<N>)
The type is a reference to custom type.
Primitive(PrimitiveType<N>)
The type is a primitive.
Implementations§
Source§impl<N: TreeNode> Type<N>
impl<N: TreeNode> Type<N>
Sourcepub fn can_cast(kind: SyntaxKind) -> bool
pub fn can_cast(kind: SyntaxKind) -> bool
Type.
Sourcepub fn cast(inner: N) -> Option<Self>
pub fn cast(inner: N) -> Option<Self>
Casts the given node to Type.
Returns None if the node cannot be cast.
Sourcepub fn is_optional(&self) -> bool
pub fn is_optional(&self) -> bool
Determines if the type is optional.
Sourcepub fn as_map_type(&self) -> Option<&MapType<N>>
pub fn as_map_type(&self) -> Option<&MapType<N>>
Sourcepub fn into_map_type(self) -> Option<MapType<N>>
pub fn into_map_type(self) -> Option<MapType<N>>
Sourcepub fn unwrap_map_type(self) -> MapType<N>
pub fn unwrap_map_type(self) -> MapType<N>
Sourcepub fn as_array_type(&self) -> Option<&ArrayType<N>>
pub fn as_array_type(&self) -> Option<&ArrayType<N>>
Attempts to get a reference to the inner ArrayType.
- If
selfis aType::Array, then a reference to the innerArrayTypeis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_array_type(self) -> Option<ArrayType<N>>
pub fn into_array_type(self) -> Option<ArrayType<N>>
Consumes self and attempts to return the inner ArrayType.
- If
selfis aType::Array, then the innerArrayTypeis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn unwrap_array_type(self) -> ArrayType<N>
pub fn unwrap_array_type(self) -> ArrayType<N>
Sourcepub fn as_pair_type(&self) -> Option<&PairType<N>>
pub fn as_pair_type(&self) -> Option<&PairType<N>>
Attempts to get a reference to the inner PairType.
- If
selfis aType::Pair, then a reference to the innerPairTypeis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_pair_type(self) -> Option<PairType<N>>
pub fn into_pair_type(self) -> Option<PairType<N>>
Consumes self and attempts to return the inner PairType.
- If
selfis aType::Pair, then the innerPairTypeis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn unwrap_pair_type(self) -> PairType<N>
pub fn unwrap_pair_type(self) -> PairType<N>
Sourcepub fn as_object_type(&self) -> Option<&ObjectType<N>>
pub fn as_object_type(&self) -> Option<&ObjectType<N>>
Attempts to get a reference to the inner ObjectType.
- If
selfis aType::Object, then a reference to the innerObjectTypeis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_object_type(self) -> Option<ObjectType<N>>
pub fn into_object_type(self) -> Option<ObjectType<N>>
Consumes self and attempts to return the inner ObjectType.
- If
selfis aType::Object, then the innerObjectTypeis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn unwrap_object_type(self) -> ObjectType<N>
pub fn unwrap_object_type(self) -> ObjectType<N>
Sourcepub fn as_type_ref(&self) -> Option<&TypeRef<N>>
pub fn as_type_ref(&self) -> Option<&TypeRef<N>>
Sourcepub fn into_type_ref(self) -> Option<TypeRef<N>>
pub fn into_type_ref(self) -> Option<TypeRef<N>>
Sourcepub fn unwrap_type_ref(self) -> TypeRef<N>
pub fn unwrap_type_ref(self) -> TypeRef<N>
Sourcepub fn as_primitive_type(&self) -> Option<&PrimitiveType<N>>
pub fn as_primitive_type(&self) -> Option<&PrimitiveType<N>>
Attempts to get a reference to the inner PrimitiveType.
- If
selfis aType::Primitive, then a reference to the innerPrimitiveTypeis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_primitive_type(self) -> Option<PrimitiveType<N>>
pub fn into_primitive_type(self) -> Option<PrimitiveType<N>>
Consumes self and attempts to return the inner PrimitiveType.
- If
selfis aType::Primitive, then the innerPrimitiveTypeis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn unwrap_primitive_type(self) -> PrimitiveType<N>
pub fn unwrap_primitive_type(self) -> PrimitiveType<N>
Trait Implementations§
impl<N: Eq + TreeNode> Eq for Type<N>
Auto Trait Implementations§
impl<N> Freeze for Type<N>where
N: Freeze,
impl<N> RefUnwindSafe for Type<N>where
N: RefUnwindSafe,
impl<N> Send for Type<N>where
N: Send,
impl<N> Sync for Type<N>where
N: Sync,
impl<N> Unpin for Type<N>where
N: Unpin,
impl<N> UnwindSafe for Type<N>where
N: UnwindSafe,
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