pub fn const_pointer_cast(val: &ValueRef, to_type: &TypeRef) -> ValueRef
Expand description
Perform a pointer cast operation on a constant value to the specified type.
§Details
Casts a constant pointer value to a different pointer type without changing the address or bit representation.
This function wraps the LLVMConstPointerCast
function from the LLVM core library. It generates a constant
pointer cast, which reinterprets the pointer value represented by ValueRef
as a different pointer type specified
by to_type
. The cast does not alter the underlying address or bit representation of the pointer; it simply changes
the type of the pointer. This is typically used when you need to change the type of a pointer while preserving its
address in memory.
§Parameters
to_type
: A reference to the target pointer type (TypeRef
) to which the pointer value should be cast. The target type must be a pointer type, but it may point to a different type than the original pointer.
§Returns
Returns an instance of ValueRef
, which encapsulates the result of the pointer cast. The result is a constant value
determined at compile time, representing the pointer value reinterpreted as the new type.