Skip to main content

Module reflection

Module reflection 

Source
🔬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_idExperimentalvalidated
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_lenExperimentalvalidated
Gets the length of the array represented by this TypeId.
type_id_element_tyExperimentalvalidated
Gets the type of each element of the array or slice represented by this TypeId.
type_id_eqExperimentalvalidated
Tests (at compile-time) if two crate::any::TypeId instances 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_typeExperimentalvalidated
Gets the FieldRepresentingType’s TypeId at the given index of the type represented by this TypeId.
type_id_fieldsExperimentalvalidated
Gets the number of fields at the given variant_index represented by this TypeId.
type_id_function_ptrExperimentalvalidated
Given a TypeId that represents a function pointer returns an core::mem::type_info::FnPtr. When called on something else this returns None.
type_id_genericsExperimentalvalidated
Returns the list of generic args on this type. Only meaningful for Adts, closures, … Everything else returns an empty slice.
type_id_is_signedExperimentalvalidated
Returns whether the type represented by this TypeId is a signed integer.
type_id_non_exhaustiveExperimentalvalidated
Checks whether this type is non-exhaustive.
type_id_points_mutablyExperimentalvalidated
Given a TypeId that represents a pointer returns whether that pointer is mutable. When called on anything else this returns false.
type_id_points_toExperimentalvalidated
Given a TypeId that represents a pointer this returns the TypeId which that pointer points to. When called on anything else this returns None.
type_id_size_ofExperimentalvalidated
Gets the size of the type represented by this TypeId.
type_id_type_ofExperimentalvalidated
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_nameExperimentalvalidated
Gets the name of the variant represented by the base TypeId and variant_idx.
type_id_variant_non_exhaustiveExperimentalvalidated
Returns true when the variant represented by the base TypeId and variant_idx is non exhaustive.
type_id_variantsExperimentalvalidated
Gets the number of variants of the type represented by this TypeId.
type_id_vtableExperimentalvalidated
Check if a type represented by a TypeId implements a trait represented by a TypeId. 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_nameExperimentalvalidated
Gets a static string slice containing the name of a type.