pub enum Type {
Atomic(AtomicTy),
Reference(ReferenceTy),
Named(NamedTy),
Array(ArrayTy),
Function(FunctionTy),
Error(Fragment),
}ast-models only.Expand description
A type signature in source code.
Variants§
Atomic(AtomicTy)
A primitive type such as u8 or bool.
Reference(ReferenceTy)
A reference to another type, such as @u8.
Named(NamedTy)
A type referred to by name, such as String or Vec<u8>.
Array(ArrayTy)
An array or slice type, such as [u8; 4] or [u8].
Function(FunctionTy)
A function type, such as func(u8, u8) -> bool.
Error(Fragment)
A type signature that could not be parsed. The parser will have emitted an error for it.
The fragment is where the type was expected (it may be empty).
Implementations§
Source§impl Type
impl Type
Sourcepub fn matching_source(&self) -> &Fragment
pub fn matching_source(&self) -> &Fragment
Get the matching source for this type signature in source code.
Sourcepub fn downcast_primitive(&self) -> Option<&AtomicTy>
pub fn downcast_primitive(&self) -> Option<&AtomicTy>
Attempt to “downcast” this to an atomic type signature if it is one.
Sourcepub fn downcast_reference(&self) -> Option<&ReferenceTy>
pub fn downcast_reference(&self) -> Option<&ReferenceTy>
Attempt to “downcast” this to a reference type signature if it is one.
Sourcepub fn downcast_named(&self) -> Option<&NamedTy>
pub fn downcast_named(&self) -> Option<&NamedTy>
Attempt to “downcast” this to a named type signature if it is one.
Sourcepub fn downcast_array(&self) -> Option<&ArrayTy>
pub fn downcast_array(&self) -> Option<&ArrayTy>
Attempt to “downcast” this to an array/slice type signature if it is one.
Sourcepub fn downcast_function(&self) -> Option<&FunctionTy>
pub fn downcast_function(&self) -> Option<&FunctionTy>
Attempt to “downcast” this to a function type signature if it is one.
Trait Implementations§
Source§impl AstNode for Type
impl AstNode for Type
Source§fn matching_source(&self) -> &Fragment
fn matching_source(&self) -> &Fragment
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Forget for Type
impl Freeze 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more