Function get_aggregate_element

Source
pub fn get_aggregate_element(val: &ValueRef, idx: u32) -> Option<ValueRef>
Expand description

Get element of a constant aggregate (struct, array or vector) at the specified index. Returns None if the index is out of range, or it’s not possible to determine the element (e.g., because the constant is a constant expression.)

§Details

Retrieves a specific element from an aggregate constant (e.g., an array or struct).

This function wraps the LLVMGetAggregateElement function from the LLVM core library. It returns the element at the specified index (idx) from the aggregate constant represented by ValueRef. If the index is out of bounds or the element cannot be retrieved, the function returns None.

§Parameters

  • idx: The index of the element to retrieve from the aggregate constant. This index should be within the bounds of the aggregate’s elements.

§Returns

Returns an Option:

  • Some(ValueRef) containing the retrieved element if the index is valid and the element is found.
  • None if the index is out of bounds or the element cannot be retrieved.