pub fn toggle_sources(label: &str, states: &[&BoundState<bool>]) -> ViewHandleExpand description
Toggle(_:isOn: [Binding<Bool>]) — one toggle over several bindings.
The “select all” row at the top of a settings group: it reads mixed when the sources disagree, and setting it sets every one of them. There was no way to express that — a toggle took exactly one binding, so the mixed state had to be faked with a third value that nothing wrote back to.
sources is @in and generic, so the array travels by address; its
elements are real Binding<Bool>s, each seventeen bytes in a
twenty-four-byte stride, which is why they are placed by stride rather than
packed.
Swift spells this Toggle("All", sources: items, isOn: \.self) — the
isOn: [Binding<Bool>] overload exists and is what this calls, but the
compiler cannot tell it from the single-binding one and rejects the array
even with its type written out. Both spellings reach the same initialiser;
the parity case uses the one that compiles.