Unnamed repository; edit this file 'description' to name the repository.
Rollup merge of #151119 - reflect-pointers, r=oli-obk
Support pointers in type reflection Tracking issue: rust-lang/rust#146922 This PR adds support for inspecting pointers `*const T` and `*mut T` through type reflection. It does so by adding the new `Pointer` struct + variant: ```rust pub struct Pointer { /// The type of the value being pointed to. pub ty: TypeId, /// Whether this pointer is mutable or not. pub mutable: bool, } ``` This can be gathered using `Type::of`, for example: ```rust match const { Type::of::<*const u8>() }.kind { TypeKind::Pointer(pointer) => { assert_eq!(pointer.ty, TypeId::of::<u8>()); assert!(!pointer.mutable); } _ => unreachable!(), } ```
Jonathan Brouwer 3 months ago
parent 6735997 · parent 6b480a8 · commit b52c2d4
0 files changed, 0 insertions, 0 deletions