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_idExperimental
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_lenExperimental
Gets the length of the array represented by this TypeId.
type_id_element_tyExperimental
Gets the type of each element of the array or slice represented by this TypeId.
type_id_eqExperimental
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_typeExperimental
Gets the FieldRepresentingType’s TypeId at the given index of the type represented by this TypeId.
type_id_fieldsExperimental
Gets the number of fields at the given variant_index represented by this TypeId.
type_id_function_ptrExperimental
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_genericsExperimental
Returns the list of generic args on this type. Only meaningful for Adts, closures, … Everything else returns an empty slice.
type_id_is_signedExperimental
Returns whether the type represented by this TypeId is a signed integer.
type_id_non_exhaustiveExperimental
Checks whether this type is non-exhaustive.
type_id_points_mutablyExperimental
Given a TypeId that represents a pointer returns whether that pointer is mutable. When called on anything else this returns false.
type_id_points_toExperimental
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_ofExperimental
Gets the size of the type represented by this TypeId.
type_id_type_ofExperimental
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_nameExperimental
Gets the name of the variant represented by the base TypeId and variant_idx.
type_id_variant_non_exhaustiveExperimental
Returns true when the variant represented by the base TypeId and variant_idx is non exhaustive.
type_id_variantsExperimental
Gets the number of variants of the type represented by this TypeId.
type_id_vtableExperimental
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_nameExperimental
Gets a static string slice containing the name of a type.