Skip to main content

view_as

Function view_as 

Source
pub unsafe fn view_as<A, B, S, D>(
    array: &ArrayBase<S, D>,
) -> Result<ArrayView<'_, B, D>, CoreError>
where A: Clone, S: Data<Elem = A>, D: Dimension,
Expand description

Create a view of an array with a different element type

This function creates a view of the given array interpreting its elements as a different type. This is useful for viewing binary data as different types without copying.

§Safety

This function is unsafe because it does not check that the memory layout of the source type is compatible with the destination type.

§Arguments

  • array - The array to view

§Returns

A view of the array with elements interpreted as the new type