pub(crate) enum Type {
Show 13 variants
Path {
path: Path,
},
DynTrait(Vec<PolyTrait>, Option<Lifetime>),
Generic(Symbol),
Primitive(PrimitiveType),
BareFunction(Box<BareFunctionDecl>),
Tuple(Vec<Type>),
Slice(Box<Type>),
Array(Box<Type>, Box<str>),
RawPointer(Mutability, Box<Type>),
BorrowedRef {
lifetime: Option<Lifetime>,
mutability: Mutability,
type_: Box<Type>,
},
QPath(Box<QPathData>),
Infer,
ImplTrait(Vec<GenericBound>),
}
Expand description
Rustdoc’s representation of types, mostly based on the hir::Ty
.
Variants§
Path
A named type, which could be a trait.
This is mostly Rustdoc’s version of hir::Path
.
It has to be different because Rustdoc’s PathSegment
can contain cleaned generics.
DynTrait(Vec<PolyTrait>, Option<Lifetime>)
A dyn Trait
object: dyn for<'a> Trait<'a> + Send + 'static
Generic(Symbol)
A type parameter.
Primitive(PrimitiveType)
A primitive (aka, builtin) type.
BareFunction(Box<BareFunctionDecl>)
A function pointer: extern "ABI" fn(...) -> ...
Tuple(Vec<Type>)
A tuple type: (i32, &str)
.
Slice(Box<Type>)
A slice type (does not include the &
): [i32]
Array(Box<Type>, Box<str>)
An array type.
The String
field is a stringified version of the array’s length parameter.
RawPointer(Mutability, Box<Type>)
A raw pointer type: *const i32
, *mut i32
BorrowedRef
A reference type: &i32
, &'a mut Foo
QPath(Box<QPathData>)
A qualified path to an associated item: <Type as Trait>::Name
Infer
A type that is inferred: _
ImplTrait(Vec<GenericBound>)
An impl Trait
: impl TraitA + TraitB + ...
Implementations§
source§impl Type
impl Type
sourcepub(crate) fn without_borrowed_ref(&self) -> &Type
pub(crate) fn without_borrowed_ref(&self) -> &Type
When comparing types for equality, it can help to ignore &
wrapping.
sourcepub(crate) fn is_same(&self, other: &Self, cache: &Cache) -> bool
pub(crate) fn is_same(&self, other: &Self, cache: &Cache) -> bool
Check if two types are “potentially the same”.
This is different from Eq
, because it knows that things like
Placeholder
are possible matches for everything.
pub(crate) fn primitive_type(&self) -> Option<PrimitiveType>
sourcepub(crate) fn is_assoc_ty(&self) -> bool
pub(crate) fn is_assoc_ty(&self) -> bool
Checks if this is a T::Name
path for an associated type.
pub(crate) fn is_self_type(&self) -> bool
pub(crate) fn generics(&self) -> Option<Vec<&Type>>
pub(crate) fn is_full_generic(&self) -> bool
pub(crate) fn is_impl_trait(&self) -> bool
pub(crate) fn projection(&self) -> Option<(&Type, DefId, PathSegment)>
fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId>
Trait Implementations§
impl Eq for Type
impl StructuralEq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes
Size for each variant:
Path
: 31 bytesDynTrait
: 31 bytesGeneric
: 7 bytesPrimitive
: 1 byteBareFunction
: 15 bytesTuple
: 31 bytesSlice
: 15 bytesArray
: 31 bytesRawPointer
: 15 bytesBorrowedRef
: 15 bytesQPath
: 15 bytesInfer
: 0 bytesImplTrait
: 31 bytes