Skip to main content

equatable

Function equatable 

Source
pub fn equatable(view: &ViewHandle) -> ViewHandle
Expand description

.equatable() — wrap a view in EquatableView, whatever its type.

equatable_text does this for a Text and nothing else, because the mangled name it resolves names Text. The constraint is Content: Equatable & View, and whether a given type satisfies it is a question the runtime can answer — so this asks, instead of the binding deciding in advance which one type is allowed.

The bound is genuine, not a limitation here: a view erased into AnyView is not Equatable and cannot be made so. That is what the panic says, and it is the same thing Swift’s type checker would say at the call site.

Wrapping is the whole of it — equatable() is @inlinable with the body EquatableView(content: self), and EquatableView stores only its content, so the value is the content’s own bytes copied through its value witness. A raw memcpy would work for a Text and leak a reference for anything holding one.