I know that a certain subset of the indices of an AbstractVector{T, Missing} are not missing. I want to efficiently manipulate that subset.

How can I extract x::AbstractVector{T} from y::AbstractVector{T, Missing} such that x[i] === y[i] whenever y[i] !== missing with minimal runtime overhead at creation and at use?

I am okay with undefined behavior if I attempt to access a missing element.

This is nice, but I’m looking for something substantially faster. I would like to avoid allocating and copying data at all and have a constant runtime with respect to input length. I think this should be possible, at least in the case of Vector{Union{T, Missing}}, because Vector{Union{T, Missing}} is stored internally as a vector of data and a vector of bits representing whether each element is missing. I just want to get a handle on the internal Vector of data.

I’m looking for something like x = reinterpret(T, y).