🔬This is a nightly-only experimental API. (
core_intrinsics)Expand description
Intrinsics for compile time reflection
This are all methods operating on TypeId which is the
entry point to all compile time reflection.
Functions§
- type_id
Experimental - Gets an identifier which is globally unique to the specified type. This function will return the same value for a type regardless of whichever crate it is invoked in.
- type_
id_ array_ len Experimental - Gets the length of the array represented by this
TypeId. - type_
id_ element_ ty Experimental - Gets the type of each element of the array or slice represented by this
TypeId. - type_
id_ eq Experimental - Tests (at compile-time) if two
crate::any::TypeIdinstances identify the same type. This is necessary because at const-eval time the actual discriminating data is opaque and cannot be inspected directly. - type_
id_ field_ representing_ type Experimental - Gets the
FieldRepresentingType’sTypeIdat the given index of the type represented by thisTypeId. - type_
id_ fields Experimental - Gets the number of fields at the given
variant_indexrepresented by thisTypeId. - type_
id_ function_ ptr Experimental - Given a
TypeIdthat represents a function pointer returns ancore::mem::type_info::FnPtr. When called on something else this returnsNone. - type_
id_ generics Experimental - Returns the list of generic args on this type. Only meaningful for Adts, closures, … Everything else returns an empty slice.
- type_
id_ is_ signed Experimental - Returns whether the type represented by this
TypeIdis a signed integer. - type_
id_ non_ exhaustive Experimental - Checks whether this type is non-exhaustive.
- type_
id_ points_ mutably Experimental - Given a
TypeIdthat represents a pointer returns whether that pointer is mutable. When called on anything else this returnsfalse. - type_
id_ points_ to Experimental - Given a
TypeIdthat represents a pointer this returns theTypeIdwhich that pointer points to. When called on anything else this returns None. - type_
id_ size_ of Experimental - Gets the size of the type represented by this
TypeId. - type_
id_ type_ of Experimental - Compute the type information of a concrete type. It can only be called at compile time, the backends do not implement it.
- type_
id_ variant_ name Experimental - Gets the name of the variant represented by the base
TypeIdand variant_idx. - type_
id_ variant_ non_ exhaustive Experimental - Returns true when the variant represented by the base
TypeIdand variant_idx is non exhaustive. - type_
id_ variants Experimental - Gets the number of variants of the type represented by this
TypeId. - type_
id_ vtable Experimental - Check if a type represented by a
TypeIdimplements a trait represented by aTypeId. It can only be called at compile time, the backends do not implement it. If it implements the trait the dyn metadata gets returned for vtable access. - type_
name Experimental - Gets a static string slice containing the name of a type.