pub struct ViewHandle { /* private fields */ }Expand description
A SwiftUI view value, kept concrete.
This used to be one word: a retained AnyView, which every modifier both
consumed and produced. That made ownership trivial — a retain and a release —
and made every type this crate built a lie by one layer. Swift’s
Text("Fx").padding(4) is ModifiedContent<Text, _PaddingLayout>; erasing
each step made it ModifiedContent<AnyView, _PaddingLayout>, and the
documentation corpus could only ever match 18 of its 89 listings on type.
So the handle carries the value itself, with the metadata and View witness
needed to hand it back to Swift. AnyView is not special here — it is simply
one of the types a handle can hold, which is what Self::into_anyview
produces for the places that genuinely need erasure: a @ViewBuilder closure
returning heterogeneous branches, or a container’s children.
Ownership is the value witness table’s business now rather than the
refcount’s: initialize_with_copy to clone, destroy to drop. For a view
that is a single class reference those are still a retain and a release; for
one with several stored properties they do the right thing for each.